#if defined(ARCTIC)

#include "ctc_error.h"
#include "ctc_diag.h"
#include "sys_usw_diag.h"
#include "sys_usw_common.h"
#include "sys_usw_mchip.h"
#include "sys_usw_register.h"
#include "sys_at_discard_type.h"

#include "drv_api.h"
#include "usw/include/drv_enum.h"
#include "usw/include/drv_common.h"
#include "sys_usw_acl_api.h"

extern int32
sys_usw_diag_drop_hash_update_count(uint8 lchip, uint32 port, uint16 reason, uint64 count);

#define DIAG_IGS_ACL_LKUP_NUM       24
#define DIAG_EGS_ACL_LKUP_NUM       12
#define DIAG_LPM_TCAM_LOCAL_BIT_LEN    14
#define DIAG_LPM_TCAM_MAX_ENTRY_NUM    8192
/*egress scl key size in word*/
#define DIAF_EGS_SCL_KEY_SIZE       3
#define DIAG_PKT_HDR_ALL_LEN 64
#define DIAG_PKT_HDR_TAIL_LEN 8
#define DIAG_PKT_XHDR_LEN 16
#define SYS_AT_MC_QUEUE_NUM 6
#define SYS_VCHIP_DUAL_CORE_MODE(lchip) (drv_vchip_get_core_num(lchip) > 1)

#define DIAG_XSEC_DISCARD 1
#define DIAG_XSEC_ENCRYTP 2
#define DIAG_DESTMAPRESERVED_MC_XFIELD 0x7FFFE

#define DIAG_LOOKUP_CONFLICT "CONFLICT"
#define DIAG_LOOKUP_DEFAULT "HIT-DEFAULT-ENTRY"
#define DIAG_LOOKUP_HIT  "HIT"
#define DIAG_LOOKUP_HIT_NONE "HIT-NONE"
#define DIAG_ENABLE "ENABLE"
#define DIAG_DISABLE    "DISABLE"
#define DIAG_YES    "Y"
#define DIAG_NO     "N"

#define DIAG_DECODE_VLAN_ID(vlan_tag)       (vlan_tag & 0xFFF)
#define DIAG_DECODE_VLAN_COS(vlan_tag)      ((vlan_tag >> 13) & 0x7)
#define DIAG_DECODE_VLAN_CFI(vlan_tag)      ((vlan_tag >> 12) & 0x1)
#define DIAG_ENCODE_VLAN_TAG(id, cos, cfi)  ((cfi << 12) | (cos << 13) | id)

#define DIAG_INFO_XDATA(POS , GETDBG, DBG_M)\
    DIAG_INFO_U32_HEX(POS, "xdata(31-0)", GETDBG(V, xpi_u_gDWord_0_data_f, &DBG_M))\
    DIAG_INFO_U32_HEX(POS, "xdata(63-32)", GETDBG(V, xpi_u_gDWord_1_data_f, &DBG_M))\
    DIAG_INFO_U32_HEX(POS, "xdata(95-64)", GETDBG(V, xpi_u_gDWord_2_data_f, &DBG_M))\
    DIAG_INFO_U32_HEX(POS, "xdata(127-96)", GETDBG(V, xpi_u_gDWord_3_data_f, &DBG_M))\
    DIAG_INFO_UINT32(POS, "xdata path profile", GETDBG(V, xpi_u_gNibble_31_data_f, &DBG_M));

#define DIAG_INFO_XDATA_PROF(POS,VALUE,GETAD,AD,AD_M)\
    cmd = DRV_IOR(AD, DRV_ENTRY_FLAG);\
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, VALUE, DRV_CMD_PP_EN(cmd), &AD_M));\
    if(GETAD(V, xAdEn_f, &AD_M))\
    {\
        DIAG_INFO_UINT32(POS, "xdata profile", GETAD(V, xAdIndex_f, &AD_M))\
    }\
    else\
    {\
        DIAG_INFO_CHAR(POS, "xdata profile","DISABLE")\
    }

#define DIAG_INFO_XDATA_PROF2(POS,VALUE,GETAD,AD,AD_M)\
    cmd = DRV_IOR(AD, DRV_ENTRY_FLAG);\
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, VALUE, DRV_CMD_PP_EN(cmd), &AD_M));\
    if(GETAD(V, auxData_f, &AD_M))\
    {\
        DIAG_INFO_CHAR(POS, "xdata ", "ENABLE")\
    }\
    else\
    {\
        DIAG_INFO_CHAR(POS, "xdata ","DISABLE")\
    }

#define DIAG_INFO_XDATA_PROF3(POS,VALUE,GETAD,AD,AD_M)\
    cmd = DRV_IOR(AD, DRV_ENTRY_FLAG);\
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, VALUE, DRV_CMD_PP_EN(cmd), &AD_M));\
    if(GETAD(V, xAdEn_f, &AD_M))\
    {\
        DIAG_INFO_CHAR(POS, "xdata ", "ENABLE")\
    }\
    else\
    {\
        DIAG_INFO_CHAR(POS, "xdata ","DISABLE")\
    }



typedef struct sys_diag_pkt_trace_table_s
{
    uint32 table;
    uint32 field;
}sys_diag_pkt_trace_table_t;

enum sys_at_diag_l3da_key_type_e
{
    SYS_AT_DIAG_L3DA_TYPE_IPV4UC,
    SYS_AT_DIAG_L3DA_TYPE_IPV6UC,
    SYS_AT_DIAG_L3DA_TYPE_IPV4MC,
    SYS_AT_DIAG_L3DA_TYPE_IPV6MC,
    SYS_AT_DIAG_L3DA_TYPE_FCOE,
    SYS_AT_DIAG_L3DA_TYPE_TRILLUC,
    SYS_AT_DIAG_L3DA_TYPE_TRILLMC,

    SYS_AT_DIAG_L3DA_TYPE_MAX
};
typedef  enum sys_at_diag_l3da_key_type_e sys_at_diag_l3da_key_type_t;

enum sys_at_diag_l3sa_key_type_e
{
    SYS_AT_DIAG_L3SA_TYPE_IPV4RPF,
    SYS_AT_DIAG_L3SA_TYPE_IPV6RPF,
    SYS_AT_DIAG_L3SA_TYPE_IPV4PBR,
    SYS_AT_DIAG_L3SA_TYPE_IPV6PBR,
    SYS_AT_DIAG_L3SA_TYPE_IPV4NATSA,
    SYS_AT_DIAG_L3SA_TYPE_IPV6NATSA,
    SYS_AT_DIAG_L3SA_TYPE_FCOERPF,

    SYS_AT_DIAG_L3SA_TYPE_MAX
};
typedef  enum sys_at_diag_l3sa_key_type_e sys_at_diag_l3sa_key_type_t;

#define DIAG_VLAN_ACTION_NONE              0
#define DIAG_VLAN_ACTION_ADD               1
#define DIAG_VLAN_ACTION_DELETE            2
#define DIAG_VLAN_ACTION_MODIFY            3

STATIC int32
_sys_at_diag_pkt_tracce_drop_map(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt, uint32 discard, uint32 discard_type)
{
    uint8 pos = p_rslt->position;
    const char* drop_desc = NULL;
    const char* discard_desc = NULL;
    uint16 str_desc_len = 0;
    uint32 temp_map = (pos << 16) | discard_type;

    if (0 == discard || temp_map == p_usw_diag_master[lchip]->cur_discard_type_map)
    {
        return CTC_E_NONE;
    }
    p_rslt->dest_type = CTC_DIAG_DEST_DROP;

    if (CTC_DIAG_TRACE_POS_IPE == pos)
    {
        discard_desc = sys_at_get_discard_type_desc(discard_type + SYS_AT_DISCARD_IPE_START);
        sys_at_map_drop_reason_sys_to_ctc(discard_type + SYS_AT_DISCARD_IPE_START, &p_rslt->drop_reason);
    }
    else if (pos == CTC_DIAG_TRACE_POS_EPE)
    {
        discard_desc = sys_at_get_discard_type_desc(discard_type + SYS_AT_DISCARD_EPE_START);
        sys_at_map_drop_reason_sys_to_ctc(discard_type + SYS_AT_DISCARD_EPE_START, &p_rslt->drop_reason);
    }
    else
    {
        discard_desc = "unknown";
    }
    drop_desc = sys_usw_register_get_reason_desc(lchip, p_rslt->drop_reason);
    p_rslt->flags |= CTC_DIAG_TRACE_RSTL_FLAG_DROP_REASON;
    p_rslt->flags |= CTC_DIAG_TRACE_RSTL_FLAG_DROP_DESC;
    str_desc_len = sal_strlen(drop_desc);
    if (str_desc_len)
    {
        sal_memset(p_rslt->drop_desc, 0,CTC_DIAG_REASON_DESC_LEN);
        sal_memcpy(p_rslt->drop_desc, drop_desc, (str_desc_len < CTC_DIAG_REASON_DESC_LEN) ? str_desc_len : CTC_DIAG_REASON_DESC_LEN);
    }
    DIAG_INFO_CHAR(pos, (CTC_DIAG_TRACE_POS_IPE == pos) ? "ipe-drop" : "epe-drop", discard_desc)
    p_usw_diag_master[lchip]->cur_discard_type_map = temp_map;
    return CTC_E_NONE;
}

STATIC int32
_sys_at_diag_pkt_tracce_exception_map(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt,
                                          uint32 excp, uint32 excp_index, uint32 excp_sub_index)
{
    uint8 pos = p_rslt->position;
    uint32 temp_map = (excp_index << 16) | excp_sub_index;
    char* exception_desc[] =
    {
        "Reserved",         /* IPEEXCEPTIONINDEX_RESERVED               CBit(3,'h',"0", 1)*/
        "Bridge exception", /* IPEEXCEPTIONINDEX_BRIDGE_EXCEPTION       CBit(3,'h',"1", 1)*/
        "Route exception",  /* IPEEXCEPTIONINDEX_ROUTE_EXCEPTION        CBit(3,'h',"2", 1)*/
        "Other exception",   /* IPEEXCEPTIONINDEX_OTHER_EXCEPTION        CBit(3,'h',"3", 1)*/
        "Unknow" ,
        "Unknow" ,
        "Unknow" ,
        "Unknow" 
    };

    if (0 == excp || temp_map == p_usw_diag_master[lchip]->cur_exception_map)
    {
        return CTC_E_NONE;
    }

    p_rslt->dest_type = CTC_DIAG_DEST_CPU;
    DIAG_INFO_CHAR(pos, "exception-type",exception_desc[excp_index])
    DIAG_INFO_UINT32(pos, "exception-index", excp_index)
    DIAG_INFO_UINT32(pos, "exception-sub-index", excp_sub_index)
    p_usw_diag_master[lchip]->cur_exception_map = temp_map;
    return CTC_E_NONE;
}


STATIC int32
_sys_at_diag_pkt_trace_get_parser_info(uint8 lchip, uint8 type, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint32 value = 0;
    uint32 value1 = 0;
    char str[64] = {0};
    hw_mac_addr_t hw_mac = {0};
    ip_addr_t hw_ipv4 = 0;
    ipv6_addr_t hw_ipv6 = {0};
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    char* str_parser[] = {"1st Parsing", "2nd Parsing", "Egress Parsing"};
    char* str_l3_type[] = {"NONE", "IP", "IPV4", "IPV6", "MPLS", "MPLSUP", "ARP", "FCOE", "TRILL",
                           "ETHEROAM", "SLOWPROTO", "RESERVED", "PTP", "DOT1AE", "SATPDU", "FLEXIBLE"};

    char* str_l4_type[] = {"NONE", "TCP", "GRE", "UDP", "IPINIP", "V6INIP", "ICMP", "IGMP", "IPINV6",
                           "RESERVED", "ACHOAM", "V6INV6", "RDP", "SCTP", "DCCP", "FLEXIBLE"};
    char *sys_diag_int_encap_type[] = {"", "TCP-RAW", "TCP-PROBE", "UDP-RAW", "UDP-PROBE"};
    ds_t parser_result_tmp;
    ParserResult_m parser_result;

    sal_memset(&parser_result_tmp, 0, sizeof(DbgParserFromIpeHdrAdjInfo_m));
    sal_memset(&parser_result, 0, sizeof(ParserResult_m));
    if (0 == type)       /*ipe 1st parser*/
    {
        cmd = DRV_IOR(DbgParserFromIpeHdrAdjInfo_t, DRV_ENTRY_FLAG);
    }
    else if (1 == type)  /*ipe 2nd parser*/
    {
        cmd = DRV_IOR(DbgIpeMplsDecapInfo_t, DbgIpeMplsDecapInfo_secondParserEn_f);
        CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &value));
        if(!value)
        {
            return CTC_E_NONE;
        }
        cmd = DRV_IOR(DbgParserFromIpeIntfInfo_t, DRV_ENTRY_FLAG);
    }
    else if (2 == type)  /*epe parser*/
    {
        cmd = DRV_IOR(DbgParserFromEpeHdrAdjInfo_t, DRV_ENTRY_FLAG);
    }
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &parser_result_tmp));

    if(!GetDbgParserFromIpeHdrAdjInfo(V, valid_f, &parser_result_tmp))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = (2 == type) ? CTC_DIAG_TRACE_POS_EPE : CTC_DIAG_TRACE_POS_IPE;
    DIAG_INFO_NONE(pos, str_parser[type])
    GetDbgParserFromIpeHdrAdjInfo(A, data_f, &parser_result_tmp, &parser_result);

    GetParserResult(A, macDa_f,        &parser_result, hw_mac);
    DIAG_INFO_MAC(pos, "mac-da", hw_mac)
    GetParserResult(A, macSa_f,        &parser_result, hw_mac);
    DIAG_INFO_MAC(pos, "mac-sa", hw_mac)

    if (GetParserResult(V, svlanIdValid_f, &parser_result))
    {
        DIAG_INFO_UINT32(pos, "svlan-id", GetParserResult(V, svlanId_f, &parser_result))
        DIAG_INFO_UINT32(pos, "stag-cos", GetParserResult(V, stagCos_f, &parser_result))
    }
    if (GetParserResult(V, cvlanIdValid_f, &parser_result))
    {
        DIAG_INFO_UINT32(pos, "cvlan-id", GetParserResult(V, cvlanId_f, &parser_result))
        DIAG_INFO_UINT32(pos, "ctag-cos", GetParserResult(V, ctagCos_f, &parser_result))
    }

    DIAG_INFO_U32_HEX(pos, "ether-type", GetParserResult(V, etherType_f, &parser_result))
    DIAG_INFO_UINT32(pos, "layer2-ext-type", GetParserResult(V, layer2ExtType_f, &parser_result))
    value = GetParserResult(V, layer3Type_f, &parser_result);
    if (value < MAX_CTC_PARSER_L3_TYPE)
    {
        sal_sprintf(str, "L3TYPE_%s", str_l3_type[value]);
        DIAG_INFO_CHAR(pos, "layer3-type", str)
    }
    switch (value)
    {
        case CTC_PARSER_L3_TYPE_IPV4:
            DIAG_INFO_U32_HEX(pos, "ip-protocol", GetParserResult(V, layer3HeaderProtocol_f, &parser_result))
            GetParserResult(A, uL3Dest_gIpv4_ipDa_f,   &parser_result, &hw_ipv4);
            DIAG_INFO_IP4(pos, "ip-da", hw_ipv4)
            GetParserResult(A, uL3Source_gIpv4_ipSa_f, &parser_result, &hw_ipv4);
            DIAG_INFO_IP4(pos, "ip-sa", hw_ipv4)
            break;
        case CTC_PARSER_L3_TYPE_IPV6:
            DIAG_INFO_U32_HEX(pos, "ip-protocol", GetParserResult(V, layer3HeaderProtocol_f, &parser_result))
            GetParserResult(A, uL3Dest_gIpv6_ipDa_f,   &parser_result, hw_ipv6);
            DIAG_INFO_IP6(pos, "ip6-da", hw_ipv6)
            GetParserResult(A, uL3Source_gIpv6_ipSa_f, &parser_result, hw_ipv6);
            DIAG_INFO_IP6(pos, "ip6-sa", hw_ipv6)
            break;
        case CTC_PARSER_L3_TYPE_MPLS:
            value1 = GetParserResult(V, uL3Tos_gMpls_labelNum_f, &parser_result);
            switch (value1)
            {
                case 8:
                    GetParserResult(A, uL3Source_gMpls_mplsLabel7_f, &parser_result, &value);
                    DIAG_INFO_UINT32(pos, "mpls-label-7", value >> 12);
                case 7:
                    GetParserResult(A, uL3Source_gMpls_mplsLabel6_f, &parser_result, &value);
                    DIAG_INFO_UINT32(pos, "mpls-label-6", value >> 12);
                case 6:
                    GetParserResult(A, uL3Source_gMpls_mplsLabel5_f, &parser_result, &value);
                    DIAG_INFO_UINT32(pos, "mpls-label-5", value >> 12);
                case 5:
                    GetParserResult(A, uL3Source_gMpls_mplsLabel4_f, &parser_result, &value);
                    DIAG_INFO_UINT32(pos, "mpls-label-4", value >> 12);
                case 4:
                    GetParserResult(A, uL3Dest_gMpls_mplsLabel3_f,   &parser_result, &value);
                    DIAG_INFO_UINT32(pos, "mpls-label-3", value >> 12);
                case 3:
                    GetParserResult(A, uL3Dest_gMpls_mplsLabel2_f,   &parser_result, &value);
                    DIAG_INFO_UINT32(pos, "mpls-label-2", value >> 12);
                case 2:
                    GetParserResult(A, uL3Dest_gMpls_mplsLabel1_f,   &parser_result, &value);
                    DIAG_INFO_UINT32(pos, "mpls-label-1", value >> 12);
                case 1:
                    GetParserResult(A, uL3Dest_gMpls_mplsLabel0_f,   &parser_result, &value);
                    DIAG_INFO_UINT32(pos, "mpls-label-0", value >> 12);
                case 0:
                    break;
            }
            break;
        case CTC_PARSER_L3_TYPE_ARP:
            DIAG_INFO_UINT32(pos, "arp-op-code", GetParserResult(V, uL3Dest_gArp_arpOpCode_f, &parser_result))
            DIAG_INFO_UINT32(pos, "arp-protocol-type", GetParserResult(V, uL3Source_gArp_protocolType_f, &parser_result))
            GetParserResult(A, uL3Dest_gArp_targetIp_f, &parser_result, &hw_ipv4);
            DIAG_INFO_IP4(pos, "arp-target-ip", hw_ipv4)
            GetParserResult(A, uL3Source_gArp_senderIp_f, &parser_result, &hw_ipv4);
            DIAG_INFO_IP4(pos, "arp-sender-ip", hw_ipv4)
            GetParserResult(A, uL3Dest_gArp_targetMac_f, &parser_result, hw_mac);
            DIAG_INFO_MAC(pos, "arp-target-mac", hw_mac)
            GetParserResult(A, uL3Source_gArp_senderMac_f, &parser_result, hw_mac);
            DIAG_INFO_MAC(pos, "arp-sender-mac", hw_mac)
            break;
        case CTC_PARSER_L3_TYPE_FCOE:
            DIAG_INFO_UINT32(pos, "fcoe-did", GetParserResult(V, uL3Dest_gFcoe_fcoeDid_f, &parser_result))
            DIAG_INFO_UINT32(pos, "fcoe-sid", GetParserResult(V, uL3Source_gFcoe_fcoeSid_f, &parser_result))
            break;
        case CTC_PARSER_L3_TYPE_TRILL:
            DIAG_INFO_U32_HEX(pos, "ingress-nickname", GetParserResult(V, uL3Source_gTrill_ingressNickname_f, &parser_result))
            DIAG_INFO_U32_HEX(pos, "egress-nickname", GetParserResult(V, uL3Dest_gTrill_egressNickname_f, &parser_result))
            DIAG_INFO_UINT32(pos, "trill-is-esadi", GetParserResult(V, uL3Dest_gTrill_isEsadi_f, &parser_result))
            DIAG_INFO_UINT32(pos, "trill-is-bfd", GetParserResult(V, uL3Dest_gTrill_isTrillBfd_f, &parser_result))
            DIAG_INFO_UINT32(pos, "trill-is-bfd-echo", GetParserResult(V, uL3Dest_gTrill_isTrillBfdEcho_f, &parser_result))
            DIAG_INFO_UINT32(pos, "is-channel", GetParserResult(V, uL3Dest_gTrill_isTrillChannel_f, &parser_result))
            DIAG_INFO_UINT32(pos, "bfd-my-discrim", GetParserResult(V, uL3Dest_gTrill_trillBfdMyDiscriminator_f, &parser_result))
            if (GetParserResult(V, uL3Dest_gTrill_trillInnerVlanValid_f, &parser_result))
            {
                DIAG_INFO_UINT32(pos, "inner-vlan-id", GetParserResult(V, uL3Dest_gTrill_trillInnerVlanId_f, &parser_result))
            }
            DIAG_INFO_UINT32(pos, "trill-length", GetParserResult(V, uL3Dest_gTrill_trillLength_f, &parser_result))
            DIAG_INFO_UINT32(pos, "multi-hop", GetParserResult(V, uL3Dest_gTrill_trillMultiHop_f, &parser_result))
            DIAG_INFO_UINT32(pos, "trill-multicast", GetParserResult(V, uL3Dest_gTrill_trillMulticast_f, &parser_result))
            DIAG_INFO_UINT32(pos, "trill-version", GetParserResult(V, uL3Dest_gTrill_trillVersion_f, &parser_result))
            break;
        case CTC_PARSER_L3_TYPE_ETHER_OAM:
            DIAG_INFO_UINT32(pos, "ether-oam-level", GetParserResult(V, uL3Dest_gEtherOam_etherOamLevel_f, &parser_result))
            DIAG_INFO_UINT32(pos, "ether-oam-op-code", GetParserResult(V, uL3Dest_gEtherOam_etherOamOpCode_f, &parser_result))
            DIAG_INFO_UINT32(pos, "ether-oam-version", GetParserResult(V, uL3Dest_gEtherOam_etherOamVersion_f, &parser_result))
            break;
        case CTC_PARSER_L3_TYPE_SLOW_PROTO:
            DIAG_INFO_UINT32(pos, "slow-proto-code", GetParserResult(V, uL3Dest_gSlowProto_slowProtocolCode_f, &parser_result))
            DIAG_INFO_U32_HEX(pos, "slow-proto-flags", GetParserResult(V, uL3Dest_gSlowProto_slowProtocolFlags_f, &parser_result))
            DIAG_INFO_UINT32(pos, "slow-proto-subtype", GetParserResult(V, uL3Dest_gSlowProto_slowProtocolSubType_f, &parser_result))
            break;
        case CTC_PARSER_L3_TYPE_PTP:
            DIAG_INFO_UINT32(pos, "ptp-message", GetParserResult(V, uL3Dest_gPtp_ptpMessageType_f, &parser_result))
            DIAG_INFO_UINT32(pos, "ptp-version", GetParserResult(V, uL3Dest_gPtp_ptpVersion_f, &parser_result))
            break;
        case CTC_PARSER_L3_TYPE_SATPDU:
            DIAG_INFO_UINT32(pos, "satpdu-mef-oui", GetParserResult(V, uL3Dest_gSatPdu_mefOui_f, &parser_result))
            DIAG_INFO_UINT32(pos, "satpdu-oui-subtype", GetParserResult(V, uL3Dest_gSatPdu_ouiSubType_f, &parser_result))
            DIAG_INFO_UINT32(pos, "satpdu-pdu-byte", GetParserResult(V, uL3Dest_gSatPdu_pduByte_f, &parser_result))
            break;
        default:
            break;
    }
    DIAG_INFO_UINT32(pos, "layer3-ext-type", GetParserResult(V, layer3ExtType_f, &parser_result))
    value = GetParserResult(V, layer4Type_f, &parser_result);
    if (value < MAX_CTC_PARSER_L4_TYPE)
    {
        sal_sprintf(str, "L4TYPE_%s", str_l4_type[value]);
        DIAG_INFO_CHAR(pos, "layer4-type", str)
    }
    if (value == DRV_ENUM(DRV_PARSER_L4_TYPE_GRE))
    {
        DIAG_INFO_UINT32(pos, "gre-flags", GetParserResult(V, uL4Source_gGre_greFlags_f, &parser_result))
        DIAG_INFO_U32_HEX(pos, "gre-proto-type", GetParserResult(V, uL4Dest_gGre_greProtocolType_f, &parser_result))
        DIAG_INFO_U32_HEX(pos, "gre-key", GetParserResult(V, uL4UserData_gGre_greKey_f, &parser_result))
    }
    else if (value == DRV_ENUM(DRV_PARSER_L4_TYPE_UDP))
    {
        DIAG_INFO_UINT32(pos, "l4-src-port", GetParserResult(V, uL4Source_gPort_l4SourcePort_f, &parser_result))
        DIAG_INFO_UINT32(pos, "l4-dst-port", GetParserResult(V, uL4Dest_gPort_l4DestPort_f, &parser_result))
    }
    switch (value)
    {
        case CTC_PARSER_L4_TYPE_TCP:
        case CTC_PARSER_L4_TYPE_RDP:
        case CTC_PARSER_L4_TYPE_SCTP:
        case CTC_PARSER_L4_TYPE_DCCP:
            DIAG_INFO_UINT32(pos, "l4-src-port", GetParserResult(V, uL4Source_gPort_l4SourcePort_f, &parser_result))
            DIAG_INFO_UINT32(pos, "l4-dst-port", GetParserResult(V, uL4Dest_gPort_l4DestPort_f, &parser_result))
            break;
        default:
            break;
    }
    value = GetParserResult(V, lengthError_f, &parser_result);
    if (CTC_IS_BIT_SET(value, 0))
    {
        DIAG_INFO_CHAR(pos, "len-error", "layer2")
    }
    if (CTC_IS_BIT_SET(value, 1))
    {
        DIAG_INFO_CHAR(pos, "len-error", "layer3")
    }
    if (CTC_IS_BIT_SET(value, 2))
    {
        DIAG_INFO_CHAR(pos, "len-error", "layer4")
    }
    value = GetParserResult(V, intEncapType_f, &parser_result);
    if (DIAG_INT_ENCAP_TYPE_NONE != value)
    {
        DIAG_INFO_CHAR(pos, "int-encap-type", sys_diag_int_encap_type[value]);
    }
    if(GetParserResult(V, extType_f, &parser_result))
    {
        DIAG_INFO_UINT32(pos, "ext-type", GetParserResult(V, extType_f, &parser_result));
        DIAG_INFO_UINT32(pos, "ext-offset", GetParserResult(V, extOffset_f, &parser_result));
    }
    DIAG_INFO_UINT32(pos, "l2-decoder-index", GetParserResult(V, l2DecoderIndex_f, &parser_result))
    DIAG_INFO_UINT32(pos, "l3-decoder-index", GetParserResult(V, l3DecoderIndex_f, &parser_result))
    DIAG_INFO_UINT32(pos, "l4-decoder-index", GetParserResult(V, l4DecoderIndex_f, &parser_result))
    return CTC_E_NONE;
}


STATIC char*
_sys_at_diag_get_igr_scl_key_desc(uint8 lchip, uint32 key_type, uint8 lk_level)
{
    lk_level = !lk_level;
    if(key_type == DRV_ENUM(DRV_USERIDHASHTYPE_DISABLE))
    {
        return "";
    }
    else if(key_type == DRV_ENUM(DRV_USERIDHASHTYPE_DOUBLEVLANPORT))
    {
        return lk_level ? "DsUserIdDoubleVlanPortHashKey" :"DsUserId1DoubleVlanPortHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_SVLANPORT))
    {
        return lk_level ? "DsUserIdSvlanPortHashKey" : "DsUserId1SvlanPortHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_CVLANPORT))
    {
        return lk_level ? "DsUserIdCvlanPortHashKey" : "DsUserId1CvlanPortHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_SVLANCOSPORT))
    {
        return lk_level ? "DsUserIdSvlanCosPortHashKey" : "DsUserId1SvlanCosPortHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_CVLANCOSPORT))
    {
        return lk_level ? "DsUserIdCvlanCosPortHashKey" : "DsUserId1CvlanCosPortHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_MACPORT))
    {
        return lk_level ? "DsUserIdMacPortHashKey" : "DsUserId1MacPortHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_IPV4PORT))
    {
        return lk_level ? "DsUserIdIpv4PortHashKey" : "DsUserId1Ipv4PortHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_MAC))
    {
        return lk_level ? "DsUserIdMacHashKey" : "DsUserId1MacHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_IPV4SA))
    {
        return lk_level ? "DsUserIdIpv4SaHashKey" : "DsUserId1Ipv4SaHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_PORT))
    {
        return lk_level ? "DsUserIdPortHashKey" : "DsUserId1PortHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_SVLANMACSA))
    {
        return lk_level ? "DsUserIdSvlanMacSaHashKey" : "DsUserId1SvlanMacSaHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_SVLAN))
    {
        return lk_level ? "DsUserIdSvlanHashKey" : "DsUserId1SvlanHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_ECIDNAMESPACE))
    {
        return lk_level ? "DsUserIdEcidNameSpaceHashKey" : "DsUserId1EcidNameSpaceHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_INGECIDNAMESPACE))
    {
        return lk_level ? "DsUserIdIngEcidNameSpaceHashKey" : "DsUserId1IngEcidNameSpaceHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_IPV6SA))
    {
        return lk_level ? "DsUserIdIpv6SaHashKey" : "DsUserId1Ipv6SaHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_IPV6PORT))
    {
        return lk_level ? "DsUserIdIpv6PortHashKey" : "DsUserId1Ipv6PortHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV4))
    {
        return lk_level ? "DsUserIdTunnelIpv4HashKey" : "DsUserId1TunnelIpv4HashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV4GREKEY))
    {
        return lk_level ? "DsUserIdTunnelIpv4GreKeyHashKey" : "DsUserId1TunnelIpv4GreKeyHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV4UDP))
    {
        return lk_level ? "DsUserIdTunnelIpv4UdpHashKey" : "DsUserId1TunnelIpv4UdpHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELTRILLUCRPF))
    {
        return lk_level ? "DsUserIdTunnelTrillUcRpfHashKey" : "DsUserId1TunnelTrillUcRpfHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELTRILLUCDECAP))
    {
        return lk_level ? "DsUserIdTunnelTrillUcDecapHashKey" : "DsUserId1TunnelTrillUcDecapHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELTRILLMCRPF))
    {
        return lk_level ? "DsUserIdTunnelTrillMcRpfHashKey" : "DsUserId1TunnelTrillMcRpfHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELTRILLMCDECAP))
    {
        return lk_level ? "DsUserIdTunnelTrillMcDecapHashKey" : "DsUserId1TunnelTrillMcDecapHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELTRILLMCADJ))
    {
        return lk_level ? "DsUserIdTunnelTrillMcAdjHashKey" : "DsUserId1TunnelTrillMcAdjHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV4RPF))
    {
        return lk_level ? "DsUserIdTunnelIpv4RpfHashKey" : "DsUserId1TunnelIpv4RpfHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV4UCVXLANMODE0))
    {
        return lk_level ? "DsUserIdTunnelIpv4UcVxlanMode0HashKey" : "DsUserId1TunnelIpv4UcVxlanMode0HashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV4UCVXLANMODE1))
    {
        return lk_level ? "DsUserIdTunnelIpv4UcVxlanMode1HashKey" : "DsUserId1TunnelIpv4UcVxlanMode1HashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV6UCVXLANMODE0))
    {
        return lk_level ? "DsUserIdTunnelIpv6UcVxlanMode0HashKey" : "DsUserId1TunnelIpv6UcVxlanMode0HashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV6UCVXLANMODE1))
    {
        return lk_level ? "DsUserIdTunnelIpv6UcVxlanMode1HashKey" : "DsUserId1TunnelIpv6UcVxlanMode1HashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV4UCNVGREMODE0))
    {
        return lk_level ? "DsUserIdTunnelIpv4UcNvgreMode0HashKey" : "DsUserId1TunnelIpv4UcNvgreMode0HashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV4UCNVGREMODE1))
    {
        return lk_level ? "DsUserIdTunnelIpv4UcNvgreMode1HashKey" : "DsUserId1TunnelIpv4UcNvgreMode1HashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV6UCNVGREMODE0))
    {
        return lk_level ? "DsUserIdTunnelIpv6UcNvgreMode0HashKey" : "DsUserId1TunnelIpv6UcNvgreMode0HashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV6UCNVGREMODE1))
    {
        return lk_level ? "DsUserIdTunnelIpv6UcNvgreMode1HashKey" : "DsUserId1TunnelIpv6UcNvgreMode1HashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV4MCVXLANMODE0))
    {
        return lk_level ? "DsUserIdTunnelIpv4McVxlanMode0HashKey" : "DsUserId1TunnelIpv4McVxlanMode0HashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV4VXLANMODE1))
    {
        return lk_level ? "DsUserIdTunnelIpv4VxlanMode1HashKey" : "DsUserId1TunnelIpv4VxlanMode1HashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV6MCVXLANMODE0))
    {
        return lk_level ? "DsUserIdTunnelIpv6McVxlanMode0HashKey" : "DsUserId1TunnelIpv6McVxlanMode0HashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV6MCVXLANMODE1))
    {
        return lk_level ? "DsUserIdTunnelIpv6McVxlanMode1HashKey" : "DsUserId1TunnelIpv6McVxlanMode1HashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV4MCNVGREMODE0))
    {
        return lk_level ? "DsUserIdTunnelIpv4McNvgreMode0HashKey" : "DsUserId1TunnelIpv4McNvgreMode0HashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV4NVGREMODE1))
    {
        return lk_level ? "DsUserIdTunnelIpv4NvgreMode1HashKey" : "DsUserId1TunnelIpv4NvgreMode1HashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV6MCNVGREMODE0))
    {
        return lk_level ? "DsUserIdTunnelIpv6McNvgreMode0HashKey" : "DsUserId1TunnelIpv6McNvgreMode0HashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV6MCNVGREMODE1))
    {
        return lk_level ? "DsUserIdTunnelIpv6McNvgreMode1HashKey" : "DsUserId1TunnelIpv6McNvgreMode1HashKey";
    }
    else if(key_type == DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV4DA))
    {
        return lk_level ? "DsUserIdTunnelIpv4DaHashKey" : "DsUserId1TunnelIpv4DaHashKey";
    }
    else if(key_type == DRV_ENUM(DRV_USERIDHASHTYPE_SCLFLOWL2))
    {
        return lk_level ? "DsUserIdSclFlowL2HashKey" :"DsUserId1SclFlowL2HashKey";
    }
    else if(key_type == DRV_ENUM(DRV_USERIDHASHTYPE_IPV4DA))
    {
        return lk_level ? "DsUserId0Ipv4DaHashKey" :"DsUserId1Ipv4DaHashKey";
    }
    else if(key_type == DRV_ENUM(DRV_USERIDHASHTYPE_IPV6DA))
    {
        return lk_level ? "DsUserId0Ipv6DaHashKey" :"DsUserId1Ipv6DaHashKey";
    }
    else if(key_type == DRV_ENUM(DRV_USERIDHASHTYPE_VLANDSCPPORT))
    {
        return lk_level ? "DsUserId0VlanPortDscpHashKey" :"DsUserId1VlanPortDscpHashKey";
    }
    else if(key_type == DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV6))
    {
        return lk_level ? "DsUserIdTunnelIpv6HashKey" : "DsUserId1TunnelIpv6HashKey";
    }
    else if(key_type == DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV4CLOUDSEC))
    {
        return lk_level ? "DsUserId0TunnelIpv4CloudSecHashKey" : "DsUserId1TunnelIpv4CloudSecHashKey";
    }
    else if(key_type == DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV6CLOUDSEC))
    {
        return lk_level ? "DsUserId0TunnelIpv6CloudSecHashKey" : "DsUserId1TunnelIpv6CloudSecHashKey";
    }
    else if(key_type == DRV_ENUM(DRV_USERIDHASHTYPE_SCLFLOWL2UDF))
    {
        return lk_level ? "DsUserIdSclFlowL2UDFHashKey" :"DsUserId1SclFlowL2UDFHashKey";
    }
    else if(key_type == DRV_ENUM(DRV_USERIDHASHTYPE_SCLFLOWL3UDF))
    {
        return lk_level ? "DsUserIdSclFlowL3UDFHashKey" :"DsUserId1SclFlowL3UDFHashKey";
    }
    return "";
}


STATIC int32
_sys_at_diag_map_tcam_key_index(uint8 lchip, uint32 dbg_index, uint8 is_acl, uint8 lkup_level, uint32* o_key_index)
{
    uint32 key_index = 0xFFFFFFFF;

    key_index = dbg_index & 0x7FF;

    if(o_key_index)
    {
        *o_key_index = key_index;
    }

    return CTC_E_NONE;
}


STATIC int32
_sys_at_diag_pkt_trace_get_ipe_scl_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint32 value = 0;
    uint32 value1 = 0;
    char   str[64] = {0};
    uint8  pos = CTC_DIAG_TRACE_POS_IPE;
    uint8  is_tunnel = 0;
    uint16 lport = 0;
    uint32 hash0_keyType = 0;
    uint32 hash1_keyType = 0;
    uint8  hash0_valid = 0, hash1_valid = 0;
    uint8  tcam0_valid = 0, tcam1_valid = 0;
    //uint8  tcam_key_valid = 0;
    uint8  decode_print_valid = 0;
    //uint8  tcam_key_hit[2] = {0};
    uint8  buf_cnt[4] = {0};
    uint32 data[4] = {0};
    uint32 data_temp[4] = {0};
    uint32 ad_ds_type[4] = {0};
    uint32 ad_proc_valid[4] = {0};
    uint32 scl_userIdTcamEn[4] = {0};
    uint32 scl_userIdTcamType[4] = {0};
    char *sys_diag_l2_type[] = {"", "ETHV2", "ETHSAP", "ETHSNAP"};
    char *sys_diag_l3_type[] = {
        "",       "IP",       "IPV4",         "IPV6",
        "MPLS",   "MPLSUP",   "ARP",          "FCOE",
        "TRILL",  "ETHEROAM", "SLOWPROTO",    "RESERVED",
        "PTP",    "DOT1AE",   "SATPDU",       "FLEXIBLE"};
    char *sys_diag_l4_type[] = {
        "NONE",   "TCP",      "GRE",      "UDP",
        "IPINIP", "V6INIP",   "ICMP",     "IGMP",
        "IPINV6", "RESERVED", "ACHOAM",   "V6INV6",
        "RDP",    "SCTP",     "DCCP",     "FLEXIBLE"};
    char *sys_diag_l4_user_type_achoam[] = {
        "",          "ACHY1731", "ACHBFD",   "ACHCC",
        "ACHCV",     "ACHDLM",   "ACHILM",   "ACHILMDM",
        "ACHDLMDM",  "ACHDM",    "MCC",      "SCC"};
    char *sys_diag_l4_user_type_gre[] = {"", "GRE_C", "GRE_K", "GRE_C_K"};
    char *sys_diag_l4_user_type_tcp[] = {"", "TCPINT", "TCPINTPROBE"};
    char *sys_diag_l4_user_type_udp[] = {
        "",     "BFD",          "UDPPTP",       "RESERVED0",
        "NTP",  "RESERVED1",    "RESERVED2",    "RESERVED2",
        "VXLAN"};
    char* str_scl_key_type[] = {
            "RESERVED0",    "L3KEY160",     "IPV6KEY320",   "MACL3KEY320",
            "UDFKEY320",    "UDFKEY640",    "UDFKEY160",    "MACIPV6KEY640",
            "PKTL2",        "PKTL3L4",      "RESERVED_3",   "MACKEY160",
            "RESERVED_4",   "RESERVED_5",   "RESERVED_6",   "INVALID"
        };
    const char *svlan_type[] = {"default-svlan-id", "pkt-svlan-id"};
    const char *cvlan_type[] = {"default-cvlan-id", "pkt-cvlan-id"};
    char* str_ad_ds_type[] = {"USERID","TUNNELID"};
    uint32 scl_key_size = 0;
    uint32 tcam_userIdTcamIndex[4] = {0};
    uint32 tcam_userIdValid[4] = {0};
    DbgIpeUserIdInfo_m user_id;
    DbgUserIdHashEngineForUserId0Info_m user_id0;
    DbgUserIdHashEngineForUserId1Info_m user_id1;
    DbgUserIdTcamEngineForUserId0Info_m scl_tcam0;
    DbgUserIdTcamEngineForUserId1Info_m scl_tcam1;
    DsUserId_m dsuserid;
    DsTunnelId_m dstunnelid;
    DsTunnelIdHalf_m dstunnelidhalf;
    //DbgSclTcamEngineInfo_m tcam_engine;
    union
    {
        DbgSCLEngineDecoderSclInputInfo_m decoder_info;
        DbgSCLEngineUdfDecoderInfo_m udf_decoder;
        DbgSCLEngineL2DecoderInfo_m l2_decoder;
        DbgSCLEngineL3DecoderInfo_m l3_decoder;
        DbgSCLEngineL4DecoderInfo_m l4_decoder;
    } un;
    void *ds = (void*)&un.decoder_info;

    sal_memset(&user_id, 0, sizeof(user_id));
    cmd = DRV_IOR(DbgIpeUserIdInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &user_id));

    if (!GetDbgIpeUserIdInfo(V, valid_f, &user_id) || !GetDbgIpeUserIdInfo(V, userIdEn_f, &user_id))
    {
        return CTC_E_NONE;
    }

    /*DbgUserIdHashEngineForUserId0Info*/
    sal_memset(&user_id0, 0, sizeof(user_id0));
    cmd = DRV_IOR(DbgUserIdHashEngineForUserId0Info_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &user_id0));

    /*DbgUserIdHashEngineForUserId1Info*/
    sal_memset(&user_id1, 0, sizeof(user_id1));
    cmd = DRV_IOR(DbgUserIdHashEngineForUserId1Info_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &user_id1));

    cmd = DRV_IOR(DbgUserIdTcamEngineForUserId0Info_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &scl_tcam0));
    cmd = DRV_IOR(DbgUserIdTcamEngineForUserId1Info_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &scl_tcam1));
    //cmd = DRV_IOR(DbgSclTcamEngineInfo_t, DRV_ENTRY_FLAG);
    //CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &tcam_engine));

    sal_memset(&dsuserid, 0, sizeof(dsuserid));
    sal_memset(&dstunnelid, 0, sizeof(dstunnelid));
    sal_memset(&dstunnelidhalf, 0, sizeof(dstunnelidhalf));

    lport = GetDbgIpeUserIdInfo(V, localPhyPort_f, &user_id);
    hash0_valid = GetDbgUserIdHashEngineForUserId0Info(V, valid_f, &user_id0);
    hash0_keyType = GetDbgUserIdHashEngineForUserId0Info(V, userIdKeyType_f, &user_id0);
    hash1_valid = GetDbgUserIdHashEngineForUserId1Info(V, valid_f, &user_id1);
    hash1_keyType =GetDbgUserIdHashEngineForUserId1Info(V, userIdKeyType_f, &user_id1);
    scl_userIdTcamEn[0] = hash0_valid && hash0_keyType;
    scl_userIdTcamEn[1] = hash1_valid && hash1_keyType;
    tcam0_valid = GetDbgUserIdTcamEngineForUserId0Info(V, valid_f, &scl_tcam0);
    tcam1_valid = GetDbgUserIdTcamEngineForUserId1Info(V, valid_f, &scl_tcam1);
    scl_userIdTcamEn[2] = tcam0_valid && GetDbgUserIdTcamEngineForUserId0Info(V, lookupEnable_f, &scl_tcam0);
    scl_userIdTcamEn[3] = tcam1_valid && GetDbgUserIdTcamEngineForUserId1Info(V, lookupEnable_f, &scl_tcam1);

    if (!(scl_userIdTcamEn[0] || scl_userIdTcamEn[1] || scl_userIdTcamEn[2] || scl_userIdTcamEn[3]))
    {
        return CTC_E_NONE;
    }

    p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
    DIAG_INFO_NONE(pos, "SCL")

    ad_ds_type[0] = GetDbgIpeUserIdInfo(V, process0AdDsType_f, &user_id);
    ad_ds_type[1] = GetDbgIpeUserIdInfo(V, process1AdDsType_f, &user_id);
    ad_ds_type[2] = GetDbgIpeUserIdInfo(V, process2AdDsType_f, &user_id);
    ad_ds_type[3] = GetDbgIpeUserIdInfo(V, process3AdDsType_f, &user_id);
    ad_proc_valid[0] = GetDbgIpeUserIdInfo(V, adProcessValid0_f, &user_id);
    ad_proc_valid[1] = GetDbgIpeUserIdInfo(V, adProcessValid1_f, &user_id);
    ad_proc_valid[2] = GetDbgIpeUserIdInfo(V, adProcessValid2_f, &user_id);
    ad_proc_valid[3] = GetDbgIpeUserIdInfo(V, adProcessValid3_f, &user_id);

    decode_print_valid = (scl_userIdTcamEn[0] && !GetDbgUserIdHashEngineForUserId0Info(V, lookupResultValid_f, &user_id0)) ||
                         (scl_userIdTcamEn[1] && !GetDbgUserIdHashEngineForUserId1Info(V, lookupResultValid_f, &user_id1)) ||
                         (scl_userIdTcamEn[2] && !GetDbgUserIdTcamEngineForUserId0Info(V, lookupResultValid_f, &scl_tcam0)) ||
                         (scl_userIdTcamEn[3] && !GetDbgUserIdTcamEngineForUserId1Info(V, lookupResultValid_f, &scl_tcam1));
    cmd = DRV_IOR(DbgSCLEngineDecoderSclInputInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), ds));
    if (GetDbgSCLEngineDecoderSclInputInfo(V, valid_f, ds) && decode_print_valid)
    {
        DIAG_INFO_NONE(pos, "--SCL Decoder Info")
        DIAG_INFO_U32_HEX(pos, "global-port", SYS_MAP_DRV_GPORT_TO_CTC_GPORT(GetDbgSCLEngineDecoderSclInputInfo(V, globalSrcPort_f, ds)))
        DIAG_INFO_UINT32(pos, "local-port", GetDbgSCLEngineDecoderSclInputInfo(V, localPhyPort_f, ds))
        DIAG_INFO_UINT32(pos, "logic-port", GetDbgSCLEngineDecoderSclInputInfo(V, logicSrcPort_f, ds))
        DIAG_INFO_UINT32(pos, "udf-hit-index", GetDbgSCLEngineDecoderSclInputInfo(V, udfHitIndex_f, ds))
        DIAG_INFO_UINT32(pos, "vlan-num", GetDbgSCLEngineDecoderSclInputInfo(V, vlanNum_f, ds))
        if (GetDbgSCLEngineDecoderSclInputInfo(V, userIdVlanRangeValid_f, ds))
        {
            DIAG_INFO_CHAR(pos, "vlan-range-type", GetDbgSCLEngineDecoderSclInputInfo(V, vlanRangeType_f, ds) ? "svlan" : "cvlan")
            DIAG_INFO_UINT32(pos, "vlan-range-max", GetDbgSCLEngineDecoderSclInputInfo(V, userIdVlanRangeMax_f, ds))
        }
        if (GetDbgSCLEngineDecoderSclInputInfo(V, tempSvlanIdValid_f, ds))
        {
            DIAG_INFO_UINT32(pos, svlan_type[GetDbgSCLEngineDecoderSclInputInfo(V, svlanIdValid_f, ds)], GetDbgSCLEngineDecoderSclInputInfo(V, tempSvlanId_f, ds))
            DIAG_INFO_UINT32(pos, "stag-cos", GetDbgSCLEngineDecoderSclInputInfo(V, stagCos_f, ds))
            DIAG_INFO_UINT32(pos, "stag-cfi", GetDbgSCLEngineDecoderSclInputInfo(V, stagCfi_f, ds))
        }
        if (GetDbgSCLEngineDecoderSclInputInfo(V, tempCvlanIdValid_f, ds))
        {
            DIAG_INFO_UINT32(pos, cvlan_type[GetDbgSCLEngineDecoderSclInputInfo(V, cvlanIdValid_f, ds)], GetDbgSCLEngineDecoderSclInputInfo(V, tempCvlanId_f, ds))
            DIAG_INFO_UINT32(pos, "ctag-cos", GetDbgSCLEngineDecoderSclInputInfo(V, ctagCos_f, ds))
            DIAG_INFO_UINT32(pos, "ctag-cfi", GetDbgSCLEngineDecoderSclInputInfo(V, ctagCfi_f, ds))
        }
        DIAG_INFO_CHAR(pos, "l2-type", sys_diag_l2_type[GetDbgSCLEngineDecoderSclInputInfo(V, layer2Type_f, ds)])
        DIAG_INFO_UINT32(pos, "l2-decode-index", GetDbgSCLEngineDecoderSclInputInfo(V, l2DecoderIndex_f, ds))
        value = GetDbgSCLEngineDecoderSclInputInfo(V, layer3Type_f, ds);
        DIAG_INFO_CHAR(pos, "l3-type", sys_diag_l3_type[value])
        DIAG_INFO_UINT32(pos, "l3-offset", GetDbgSCLEngineDecoderSclInputInfo(V, layer3Offset_f, ds))
        DIAG_INFO_UINT32(pos, "l3-decode-index", GetDbgSCLEngineDecoderSclInputInfo(V, l3DecoderIndex_f, ds))
        DIAG_INFO_UINT32(pos, "frag-info", GetDbgSCLEngineDecoderSclInputInfo(V, fragInfo_f, ds))
        DIAG_INFO_UINT32(pos, "ip-options", GetDbgSCLEngineDecoderSclInputInfo(V, ipOptions_f, ds))
        DIAG_INFO_UINT32(pos, "ip-pkt-len-range-id", GetDbgSCLEngineDecoderSclInputInfo(V, ipPktLenRangeId_f, ds))
        DIAG_INFO_UINT32(pos, "ip-hdr-error", GetDbgSCLEngineDecoderSclInputInfo(V, ipHeaderError_f, ds))
        if ((value == DIAG_L3TYPE_MPLS) || (value == DIAG_L3TYPE_MPLSUP))
        {
            DIAG_INFO_UINT32(pos, "label-num", GetDbgSCLEngineDecoderSclInputInfo(V, labelNum_f, ds))
        }
        value = GetDbgSCLEngineDecoderSclInputInfo(V, layer4Type_f, ds);
        DIAG_INFO_CHAR(pos, "l4-type", sys_diag_l4_type[value])
        DIAG_INFO_UINT32(pos, "l4-offset", GetDbgSCLEngineDecoderSclInputInfo(V, layer4Offset_f, ds))
        DIAG_INFO_UINT32(pos, "l4-decode-index", GetDbgSCLEngineDecoderSclInputInfo(V, l4DecoderIndex_f, ds))
        value1 = GetDbgSCLEngineDecoderSclInputInfo(V, layer4UserType_f, ds);
        switch(value)
        {
            case DIAG_L4TYPE_TCP:
                DIAG_INFO_CHAR(pos, "l4-user-type", sys_diag_l4_user_type_tcp[value1])
                break;
            case DIAG_L4TYPE_UDP:
                DIAG_INFO_CHAR(pos, "l4-user-type", sys_diag_l4_user_type_udp[value1])
                break;
            case DIAG_L4TYPE_GRE:
                DIAG_INFO_CHAR(pos, "l4-user-type", sys_diag_l4_user_type_gre[value1])
                break;
            case DIAG_L4TYPE_ACHOAM:
                DIAG_INFO_CHAR(pos, "l4-user-type", sys_diag_l4_user_type_achoam[value1])
                break;
            default:
                DIAG_INFO_UINT32(pos, "l4-user-type", value)
                break;
        }
        if (GetDbgSCLEngineDecoderSclInputInfo(V, customerIdValid_f, ds))
        {
            DIAG_INFO_UINT32(pos, "customer-id", GetDbgSCLEngineDecoderSclInputInfo(V, customerId_f, ds))
        }
        DIAG_INFO_UINT32(pos, "ext-type", GetDbgSCLEngineDecoderSclInputInfo(V, extType_f, ds))
        DIAG_INFO_UINT32(pos, "ext-offset", GetDbgSCLEngineDecoderSclInputInfo(V, extOffset_f, ds))
        DIAG_INFO_UINT32(pos, "parser-len", GetDbgSCLEngineDecoderSclInputInfo(V, parserLength_f, ds))
        DIAG_INFO_UINT32(pos, "mux-destination", GetDbgSCLEngineDecoderSclInputInfo(V, muxDestination_f, ds))
        DIAG_INFO_UINT32(pos, "tcp-data-offset", GetDbgSCLEngineDecoderSclInputInfo(V, tcpDataOffset_f, ds))
        DIAG_INFO_U32_HEX(pos, "l4-port-range-bimap", GetDbgSCLEngineDecoderSclInputInfo(V, l4PortRangeBitmap_f, ds))
        DIAG_INFO_UINT32(pos, "ecid", GetDbgSCLEngineDecoderSclInputInfo(V, ecid_f, ds))
        DIAG_INFO_UINT32(pos, "name-space", GetDbgSCLEngineDecoderSclInputInfo(V, ecidNameSpace_f, ds))
        DIAG_INFO_UINT32(pos, "is-vxlan", GetDbgSCLEngineDecoderSclInputInfo(V, isVxlan_f, ds))
        DIAG_INFO_UINT32(pos, "is-cloud-sec", GetDbgSCLEngineDecoderSclInputInfo(V, isCloudSec_f, ds))
        DIAG_INFO_UINT32(pos, "hmac-check-en", GetDbgSCLEngineDecoderSclInputInfo(V, hmacCheckEn_f, ds))
    }
    cmd = DRV_IOR(DbgSCLEngineUdfDecoderInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), ds));
    if (GetDbgSCLEngineUdfDecoderInfo(V, valid_f, ds))
    {
        DIAG_INFO_NONE(pos, "--SCL UDF Decoder")
        switch(GetDbgSCLEngineUdfDecoderInfo(V, fibKeyUdfSelType_f, ds))
        {
            case 1:
            {
                DIAG_INFO_CHAR(pos, "fib-ipv6-da use", "UDF")
                break;
            }
            case 2:
            {
                DIAG_INFO_CHAR(pos, "fib-mac-da use", "UDF")
                break;
            }
            case 3:
            {
                DIAG_INFO_CHAR(pos, "fib-mac-sa use", "UDF")
                break;
            }
            case 0:
            default:
                break;
        }
        if (GetDbgSCLEngineUdfDecoderInfo(V, udfValid_f, ds))
        {
            uint16 udf_ad_id = GetDbgSCLEngineUdfDecoderInfo(V, udfHitIndex_f, ds);
            sys_acl_udf_info_t udf_info = {0};
            DIAG_INFO_CHAR(pos, "udf-lkup", DIAG_LOOKUP_HIT)
            DIAG_INFO_CHAR(pos, "xlookup", GetDbgSCLEngineUdfDecoderInfo(V, xLookupUdfEn_f, ds) ? DIAG_ENABLE :DIAG_DISABLE)
            DIAG_INFO_UINT32(pos, "udf-hit-index", udf_ad_id)
            GetDbgSCLEngineUdfDecoderInfo(A, udf_f, ds, data);

            sys_usw_acl_get_udf_info_by_ad_id(lchip, udf_ad_id, &udf_info);
            DIAG_SET_USR_UDF(udf_info.granularity, data_temp,data);
            DIAG_INFO_UDF(pos, "udf-data", data_temp);

        }
        else
        {
            DIAG_INFO_CHAR(pos, "udf-lkup", DIAG_LOOKUP_HIT_NONE)
        }
    }
    cmd = DRV_IOR(DbgSCLEngineL2DecoderInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), ds));
    if (GetDbgSCLEngineL2DecoderInfo(V, valid_f, ds) && decode_print_valid)
    {
        DIAG_INFO_NONE(pos, "--SCL L2 Decoder")
        GetDbgSCLEngineL2DecoderInfo(A, macDa_f, ds, data);
        DIAG_INFO_MAC(pos, "mac-da", data)
        GetDbgSCLEngineL2DecoderInfo(A, macSa_f, ds, data);
        DIAG_INFO_MAC(pos, "mac-sa", data)
        DIAG_INFO_UINT32(pos, "ether-type", GetDbgSCLEngineL2DecoderInfo(V, etherType_f, ds))
        DIAG_INFO_UINT32(pos, "svlan-id", GetDbgSCLEngineL2DecoderInfo(V, svlanTag_f, ds))
        DIAG_INFO_UINT32(pos, "cvlan-id", GetDbgSCLEngineL2DecoderInfo(V, cvlanTag_f, ds))
        DIAG_INFO_U32_HEX(pos, "data0", GetDbgSCLEngineL2DecoderInfo(V, data0_f, ds))
        DIAG_INFO_U32_HEX(pos, "data1", GetDbgSCLEngineL2DecoderInfo(V, data1_f, ds))
    }
    cmd = DRV_IOR(DbgSCLEngineL3DecoderInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), ds));
    if (GetDbgSCLEngineL3DecoderInfo(V, valid_f, ds) && decode_print_valid)
    {
        DIAG_INFO_NONE(pos, "--SCL L3 Decoder")
        DIAG_INFO_U32_HEX(pos, "data0", GetDbgSCLEngineL3DecoderInfo(V, uF0_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "data1", GetDbgSCLEngineL3DecoderInfo(V, uF1_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "data2", GetDbgSCLEngineL3DecoderInfo(V, uF2_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "data3", GetDbgSCLEngineL3DecoderInfo(V, uF3_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "data4", GetDbgSCLEngineL3DecoderInfo(V, uF4_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "data5", GetDbgSCLEngineL3DecoderInfo(V, uF5_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "data6", GetDbgSCLEngineL3DecoderInfo(V, uF6_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "data7", GetDbgSCLEngineL3DecoderInfo(V, uF7_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "data8", GetDbgSCLEngineL3DecoderInfo(V, uF8_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "data9", GetDbgSCLEngineL3DecoderInfo(V, uF9_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "data10", GetDbgSCLEngineL3DecoderInfo(V, uF10_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "data11", GetDbgSCLEngineL3DecoderInfo(V, uF11_gField_data_f, ds))
    }
    cmd = DRV_IOR(DbgSCLEngineL4DecoderInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), ds));
    if (GetDbgSCLEngineL4DecoderInfo(V, valid_f, ds) && decode_print_valid)
    {
        DIAG_INFO_NONE(pos, "--SCL L4 Decoder")
        DIAG_INFO_U32_HEX(pos, "data0", GetDbgSCLEngineL4DecoderInfo(V, uF0_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "data1", GetDbgSCLEngineL4DecoderInfo(V, uF1_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "data2", GetDbgSCLEngineL4DecoderInfo(V, uF2_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "data3", GetDbgSCLEngineL4DecoderInfo(V, uF3_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "data4", GetDbgSCLEngineL4DecoderInfo(V, uF4_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "data5", GetDbgSCLEngineL4DecoderInfo(V, uF5_gField_data_f, ds))
    }

    cmd = DRV_IOR(DsPhyPortExt_t, DsPhyPortExt_userIdResultPriorityMode_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, lport, DRV_CMD_PP_EN(cmd), &value));
    switch (value)
    {
        case 0:
            buf_cnt[0] = 0;
            buf_cnt[1] = 1;
            buf_cnt[2] = 2;
            buf_cnt[3] = 3;
            break;
        case 1:
            buf_cnt[2] = 0;
            buf_cnt[0] = 1;
            buf_cnt[1] = 2;
            buf_cnt[3] = 3;
            break;
        case 2:
            buf_cnt[2] = 0;
            buf_cnt[3] = 1;
            buf_cnt[0] = 2;
            buf_cnt[1] = 3;
            break;
        case 3:
            buf_cnt[0] = 0;
            buf_cnt[2] = 1;
            buf_cnt[1] = 2;
            buf_cnt[3] = 3;
            break;
        case 4:
            buf_cnt[2] = 0;
            buf_cnt[0] = 1;
            buf_cnt[3] = 2;
            buf_cnt[1] = 3;
            break;
        default:
            break;
    }

    DIAG_INFO_NONE(pos, "--SCL Lookup Info")
    for (value = 0; value < 4; value++)
    {
        if (ad_proc_valid[buf_cnt[value]])
        {
            sal_sprintf(str, "ad-type-%d", value);
            DIAG_INFO_CHAR(pos, str, str_ad_ds_type[ad_ds_type[buf_cnt[value]]])
        }
    }

    if (GetDbgIpeUserIdInfo(V, routerMacHit_f, &user_id))
    {
        if (GetDbgIpeUserIdInfo(V, routerMacLookupEn_f, &user_id))
        {
            value = GetDbgIpeUserIdInfo(V, routerMacTcamHit_f, &user_id);
            DIAG_INFO_CHAR(pos, "Route-MAC-Tcam", value? DIAG_LOOKUP_HIT: DIAG_LOOKUP_HIT_NONE)
        }
        else
        {
            value = GetDbgIpeUserIdInfo(V, isRouterMac_f, &user_id);
            DIAG_INFO_CHAR(pos, "SCL-Hit-Route-MAC", value? DIAG_LOOKUP_HIT: DIAG_LOOKUP_HIT_NONE)
        }
    }

    /*hash0*/
    if (hash0_keyType && hash0_valid)
    {
        value = GetDbgUserIdHashEngineForUserId0Info(V, keyIndex_f, &user_id0);
        value1 = GetDbgUserIdHashEngineForUserId0Info(V, debugAdIndex_f, &user_id0);
        if (GetDbgUserIdHashEngineForUserId0Info(V, debugTcamResultValid_f, &user_id0) || GetDbgUserIdHashEngineForUserId0Info(V, hashConflict_f, &user_id0))
        {
            DIAG_INFO_CHAR(pos, "hash-0-lookup-result", DIAG_LOOKUP_CONFLICT)
            DIAG_INFO_CHAR(pos, "flex-key", GetDbgUserIdHashEngineForUserId0Info(V, xKeyValid_f, &user_id0) ? DIAG_LOOKUP_HIT : DIAG_LOOKUP_HIT_NONE)
            DIAG_INFO_UINT32(pos, "key-index", value)
            DIAG_INFO_CHAR(pos, "key-name", _sys_at_diag_get_igr_scl_key_desc(lchip, hash0_keyType, 0))
        }
        else if (GetDbgUserIdHashEngineForUserId0Info(V, defaultEntryValid_f, &user_id0))
        {
            DIAG_INFO_CHAR(pos, "hash-0-lookup-result", DIAG_LOOKUP_DEFAULT)
        }
        else if (GetDbgUserIdHashEngineForUserId0Info(V, lookupResultValid_f, &user_id0))
        {
            DIAG_INFO_CHAR(pos, "hash-0-lookup-result", DIAG_LOOKUP_HIT)
            DIAG_INFO_CHAR(pos, "flex-key", GetDbgUserIdHashEngineForUserId0Info(V, xKeyValid_f, &user_id0) ? DIAG_LOOKUP_HIT : DIAG_LOOKUP_HIT_NONE)
        }
        else
        {
            DIAG_INFO_CHAR(pos, "hash-0-lookup-result", DIAG_LOOKUP_HIT_NONE)
        }
        is_tunnel = (hash0_keyType >= DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV4)) && (hash0_keyType < DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV6CLOUDSEC));
        if (GetDbgUserIdHashEngineForUserId0Info(V, defaultEntryValid_f, &user_id0)
            || GetDbgUserIdHashEngineForUserId0Info(V, lookupResultValid_f, &user_id0))
        {
            DIAG_INFO_UINT32(pos, "key-index", value)
            DIAG_INFO_CHAR(pos, "key-name", _sys_at_diag_get_igr_scl_key_desc(lchip, hash0_keyType, 0))
            DIAG_INFO_UINT32(pos, "ad-index", value1)

            if (hash0_keyType && !is_tunnel)
            {
                cmd = DRV_IOR(DsUserIdHalf_t, DsUserIdHalf_isHalf_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, value1, DRV_CMD_PP_EN(cmd), &value));
                if (value)
                {
                    DIAG_INFO_CHAR(pos, "ad-name", "DsUserIdHalf")
                }
                else
                {
                    DIAG_INFO_CHAR(pos, "ad-name", "DsUserId")
                    DIAG_INFO_XDATA_PROF(pos,value1,GetDsUserId,DsUserId_t,dsuserid)
                }
            }
            else if (hash0_keyType)
            {
                cmd = DRV_IOR(DsTunnelIdHalf_t, DsTunnelIdHalf_isHalf_f);
                DRV_FIELD_IOCTL(lchip, value1, DRV_CMD_PP_EN(cmd), &value);
                if (value)
                {
                    DIAG_INFO_CHAR(pos, "ad-name", "DsTunnelIdHalf")
                    DIAG_INFO_XDATA_PROF(pos,value1,GetDsTunnelIdHalf,DsTunnelIdHalf_t,dstunnelidhalf)
                }
                else
                {
                    DIAG_INFO_CHAR(pos, "ad-name", "DsTunnelId")
                    DIAG_INFO_XDATA_PROF(pos,value1,GetDsTunnelId,DsTunnelId_t,dstunnelid)
                }
            }
        }
    }

    /*hash1*/
    if (hash1_keyType && hash1_valid)
    {
        value = GetDbgUserIdHashEngineForUserId1Info(V, keyIndex_f, &user_id1);
        value1 = GetDbgUserIdHashEngineForUserId1Info(V, debugAdIndex_f, &user_id1);
        if (GetDbgUserIdHashEngineForUserId1Info(V, debugTcamResultValid_f, &user_id1) || GetDbgUserIdHashEngineForUserId1Info(V, hashConflict_f, &user_id1))
        {
            DIAG_INFO_CHAR(pos, "hash-1-lookup-result", DIAG_LOOKUP_CONFLICT)
            DIAG_INFO_CHAR(pos, "flex-key", GetDbgUserIdHashEngineForUserId1Info(V, xKeyValid_f, &user_id1) ? DIAG_LOOKUP_HIT : DIAG_LOOKUP_HIT_NONE)
            DIAG_INFO_UINT32(pos, "key-index", value)
            DIAG_INFO_CHAR(pos, "key-name", _sys_at_diag_get_igr_scl_key_desc(lchip, hash1_keyType, 1))
        }
        else if (GetDbgUserIdHashEngineForUserId1Info(V, defaultEntryValid_f, &user_id1))
        {
            DIAG_INFO_CHAR(pos, "hash-1-lookup-result", DIAG_LOOKUP_DEFAULT)
        }
        else if (GetDbgUserIdHashEngineForUserId1Info(V, lookupResultValid_f, &user_id1))
        {
            DIAG_INFO_CHAR(pos, "hash-1-lookup-result", DIAG_LOOKUP_HIT)
            DIAG_INFO_CHAR(pos, "flex-key", GetDbgUserIdHashEngineForUserId1Info(V, xKeyValid_f, &user_id1) ? DIAG_LOOKUP_HIT : DIAG_LOOKUP_HIT_NONE)
        }
        else
        {
            DIAG_INFO_CHAR(pos, "hash-1-lookup-result", DIAG_LOOKUP_HIT_NONE)
        }
        is_tunnel = (hash1_keyType >= DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV4)) && (hash1_keyType < DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV6CLOUDSEC));
        if (GetDbgUserIdHashEngineForUserId1Info(V, defaultEntryValid_f, &user_id1)
            || GetDbgUserIdHashEngineForUserId1Info(V, lookupResultValid_f, &user_id1))
        {
            DIAG_INFO_UINT32(pos, "key-index", value)
            DIAG_INFO_CHAR(pos, "key-name", _sys_at_diag_get_igr_scl_key_desc(lchip, hash1_keyType, 1))
            DIAG_INFO_UINT32(pos, "ad-index", value1)
            if (hash1_keyType && !is_tunnel)
            {
                cmd = DRV_IOR(DsUserIdHalf1_t, DsUserIdHalf1_isHalf_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, value1, DRV_CMD_PP_EN(cmd), &value));
                if (value)
                {
                    DIAG_INFO_CHAR(pos, "ad-name", "DsUserIdHalf1")
                }
                else
                {
                    DIAG_INFO_CHAR(pos, "ad-name", "DsUserId1")
                    DIAG_INFO_XDATA_PROF(pos,value1,GetDsUserId1,DsUserId1_t,dsuserid)
                }
            }
            else if (hash1_keyType)
            {
                cmd = DRV_IOR(DsTunnelIdHalf1_t, DsTunnelIdHalf1_isHalf_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, value1, DRV_CMD_PP_EN(cmd), &value));
                if (value)
                {
                    DIAG_INFO_CHAR(pos, "ad-name", "DsTunnelIdHalf1")
                    DIAG_INFO_XDATA_PROF(pos,value1,GetDsTunnelIdHalf1,DsTunnelIdHalf1_t,dstunnelidhalf)
                }
                else
                {
                    DIAG_INFO_CHAR(pos, "ad-name", "DsTunnelId1")
                    DIAG_INFO_XDATA_PROF(pos,value1,GetDsTunnelId1,DsTunnelId1_t,dstunnelid)
                }
            }
        }
    }

    scl_userIdTcamType[2] = GetDbgUserIdTcamEngineForUserId0Info(V, tcamKeyType_f, &scl_tcam0);
    scl_userIdTcamType[3] = GetDbgUserIdTcamEngineForUserId1Info(V, tcamKeyType_f, &scl_tcam1);
    tcam_userIdValid[2] = GetDbgUserIdTcamEngineForUserId0Info(V, lookupResultValid_f, &scl_tcam0);
    tcam_userIdValid[3] = GetDbgUserIdTcamEngineForUserId1Info(V, lookupResultValid_f, &scl_tcam1);

    tcam_userIdTcamIndex[2] = tcam_userIdValid[2]? GetDbgUserIdTcamEngineForUserId0Info(V, debugAdIndex_f, &scl_tcam0): 0xFFFFFFFF;
    tcam_userIdTcamIndex[3] = tcam_userIdValid[3]? GetDbgUserIdTcamEngineForUserId1Info(V, debugAdIndex_f, &scl_tcam1): 0xFFFFFFFF;

    /*tcam0~3*/
/* __TODO__ spec tcam 0 and 1 not provide debug info*/
    for (value1 = 2; value1 < 4; value1++)
    {
        if (!scl_userIdTcamEn[value1])
        {
            continue;
        }
        sal_sprintf(str, "tcam-%d-lookup-result",value1);
        if (tcam_userIdValid[value1])
        {
            DIAG_INFO_CHAR(pos, str, DIAG_LOOKUP_HIT)
            DIAG_INFO_CHAR(pos, "key-type", str_scl_key_type[scl_userIdTcamType[value1]])
            _sys_at_diag_map_tcam_key_index(lchip, tcam_userIdTcamIndex[value1], 0, value1, &value);
            if (value1 == 2)
            {
                scl_key_size = GetDbgUserIdTcamEngineForUserId0Info(V, keySize_f, &scl_tcam0);
                DIAG_INFO_XDATA_PROF(pos,tcam_userIdTcamIndex[2],GetDsUserId2,DsUserId2_t,dsuserid)
            }
            else if (value1 == 3)
            {
                scl_key_size = GetDbgUserIdTcamEngineForUserId1Info(V, keySize_f, &scl_tcam1);
                DIAG_INFO_XDATA_PROF(pos,tcam_userIdTcamIndex[3],GetDsUserId3,DsUserId3_t,dsuserid)
            }
            if(scl_key_size > 0)
            {
                DIAG_INFO_UINT32(pos, "key-index", value / (1 << (scl_key_size - 1)))
            }
            DIAG_INFO_UINT32(pos, "key-size", 80*(1<<scl_key_size))
        }
        else
        {
            DIAG_INFO_CHAR(pos, str, DIAG_LOOKUP_HIT_NONE)
        }
    }

    DIAG_INFO_XDATA(pos, GetDbgIpeUserIdInfo , user_id)

    /* Drop Process */
    _sys_at_diag_pkt_tracce_drop_map(lchip,p_rslt,
                                          GetDbgIpeUserIdInfo(V, discard_f, &user_id),
                                          GetDbgIpeUserIdInfo(V, discardType_f, &user_id));



    /* Exception Process */
    _sys_at_diag_pkt_tracce_exception_map(lchip,p_rslt,
                                               GetDbgIpeUserIdInfo(V, exceptionEn_f, &user_id),
                                               GetDbgIpeUserIdInfo(V, exceptionIndex_f, &user_id),
                                               GetDbgIpeUserIdInfo(V, exceptionSubIndex_f, &user_id));
    return CTC_E_NONE;
}

STATIC int32
_sys_at_diag_pkt_trace_get_ipe_intf_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint8 gchip = 0;
    uint32 value = 0;
    uint32 value1 = 0;
    uint32 vlanPtr = 0;
    uint32 cmd = 0;
    uint32 lport = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    char* vlanId_action[3] = {"NONE", "SWAP", "USER"};
    DbgIpeUserIdInfo_m user_id_info;
    DbgIpeIntfMapperInfo_m intf_mapper_info;


    sal_memset(&user_id_info, 0, sizeof(user_id_info));
    cmd = DRV_IOR(DbgIpeUserIdInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &user_id_info));
    sal_memset(&intf_mapper_info, 0, sizeof(intf_mapper_info));
    cmd = DRV_IOR(DbgIpeIntfMapperInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &intf_mapper_info));

    if (!GetDbgIpeIntfMapperInfo(V, valid_f, &intf_mapper_info))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_IPE;

    if (DIAG_XSEC_ENCRYTP == GetDbgIpeUserIdInfo(V, xSecRxOpType_f, 	&user_id_info))
    {
	    DIAG_INFO_NONE(pos, "Dot1ae Rx")
        DIAG_INFO_UINT32(pos, "sc-index", GetDbgIpeUserIdInfo(V, cryptoSc_f, &user_id_info))
        DIAG_INFO_CHAR(pos, "macsec-uncontrolled-pkt", (GetDbgIpeUserIdInfo(V, isMacsecUcPortPkt_f,  &user_id_info)) ? "YES" : "NO")
        DIAG_INFO_UINT32(pos, "sec-tag-length", GetDbgIpeUserIdInfo(V, secTagLen_f, &user_id_info))
        DIAG_INFO_UINT32(pos, "sec-tag-offset", GetDbgIpeUserIdInfo(V, secTagOffset_f, &user_id_info))
        DIAG_INFO_UINT32(pos, "sop-discard", GetDbgIpeUserIdInfo(V, xSecRxSopDiscard_f, &user_id_info))
        if (GetDbgIpeUserIdInfo(V, xSecRxSecYStatsValid_f, &user_id_info))
        {
            value = GetDbgIpeUserIdInfo(V, xSecRxSecYStatsType_f,  &user_id_info);
            DIAG_INFO_CHAR(pos, "secY-stats", (value == 2) ? "no-sa-error" : ( (value == 1)? "no-sa" : "bad-tag"))
        }
        if (GetDbgIpeUserIdInfo(V, xSecRxChanStatsValid_f, &user_id_info))
        {
            value = GetDbgIpeUserIdInfo(V, xSecRxChanStatsType_f,  &user_id_info);
            DIAG_INFO_CHAR(pos, "chan-stats", value ? "discard" :  "bypass")
        }
    }

    DIAG_INFO_NONE(pos, "Interface Mapper")

    if (GetDbgIpeUserIdInfo(V, lowLatencyEn_f, &user_id_info))
    {
        DIAG_INFO_CHAR(pos, "low-lantency", "enable")
    }

    lport = GetDbgIpeUserIdInfo(V, localPhyPort_f, &user_id_info);
    if (GetDbgIpeUserIdInfo(V, valid_f, &user_id_info))
    {
        CTC_ERROR_RETURN(drv_get_gchip_id(lchip, &gchip));
        DIAG_INFO_U32_HEX(pos, "source-port", CTC_MAP_LPORT_TO_GPORT(gchip, lport))
    }

    vlanPtr = GetDbgIpeIntfMapperInfo(V, vlanPtr_f, &intf_mapper_info);
    DIAG_INFO_UINT32(pos, "vlan-ptr", vlanPtr)
    if (GetDbgIpeIntfMapperInfo(V, svlanTagOperationValid_f, &intf_mapper_info))
    {
        value = GetDbgIpeIntfMapperInfo(V, sVlanIdAction_f, &intf_mapper_info);
        DIAG_INFO_CHAR(pos, "ingress-svlan-action", vlanId_action[value])
        if (value)
        {
            DIAG_INFO_UINT32(pos, "new-svlan-id", GetDbgIpeIntfMapperInfo(V, svlanId_f, &intf_mapper_info))
        }
    }
    if (GetDbgIpeIntfMapperInfo(V, cvlanTagOperationValid_f, &intf_mapper_info))
    {
        value = GetDbgIpeIntfMapperInfo(V, cVlanIdAction_f, &intf_mapper_info);
        DIAG_INFO_CHAR(pos, "ingress-cvlan-action", vlanId_action[value])
        if (value)
        {
            DIAG_INFO_UINT32(pos, "new-cvlan-id", GetDbgIpeIntfMapperInfo(V, cvlanId_f, &intf_mapper_info))
        }
    }
    value = GetDbgIpeIntfMapperInfo(V, interfaceId_f, &intf_mapper_info);
    if (value)
    {
        DIAG_INFO_UINT32(pos, "l3-intf-id", value)
        cmd = DRV_IOR(DsSrcInterface_t, DsSrcInterface_vrfId_f);
        CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, value, DRV_CMD_PP_EN(cmd), &value1));
        DIAG_INFO_UINT32(pos, "intf-vrfid", value1)
        DIAG_INFO_CHAR(pos, "vrfid-loop-en", GetDbgIpeIntfMapperInfo(V, vrfIdLoopEn_f, &intf_mapper_info)? DIAG_ENABLE : DIAG_DISABLE)
        DIAG_INFO_CHAR(pos, "route-mac", GetDbgIpeIntfMapperInfo(V, isRouterMac_f, &intf_mapper_info) ? "YES" : "NO")
    }
    cmd = DRV_IOR(DsSrcPort_t, DsSrcPort_portCrossConnect_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, lport, DRV_CMD_PP_EN(cmd), &value));
    if (value)
    {
        DIAG_INFO_CHAR(pos, "cross-connect", "YES")
    }
    else
    {
        /*bridge en*/
        cmd = DRV_IOR(DsSrcPort_t, DsSrcPort_bridgeEn_f);
        CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, lport, DRV_CMD_PP_EN(cmd), &value));
        if (vlanPtr < 4096)
        {
            cmd = DRV_IOR(DsSrcVlan_t, DsSrcVlan_bridgeDisable_f);
            CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, vlanPtr, DRV_CMD_PP_EN(cmd), &value1));
        }
        value = value && (!value1);
        DIAG_INFO_CHAR(pos, "bridge-port", value ?"YES":"NO")

        /*route en*/
        cmd = DRV_IOR(DsSrcPort_t, DsSrcPort_routedPort_f);
        CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, lport, DRV_CMD_PP_EN(cmd), &value));
        DIAG_INFO_CHAR(pos, "route-port", value ?"YES":"NO")
    }
    /*mpls en*/
    value = GetDbgIpeIntfMapperInfo(V, interfaceId_f, &intf_mapper_info);
    if (value)
    {
        cmd = DRV_IOR(DsSrcInterface_t, DsSrcInterface_mplsEn_f);
        CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, value, DRV_CMD_PP_EN(cmd), &value1));
        DIAG_INFO_CHAR(pos, "mpls-port", value1 ?"YES":"NO")
    }

    if (GetDbgIpeUserIdInfo(V, pduTypeValid_f, &user_id_info))
    {
        DIAG_INFO_UINT32(pos, "l2-user-pdu-type", GetDbgIpeUserIdInfo(V, pduType_f, &user_id_info))
    }

    DIAG_INFO_XDATA(pos, GetDbgIpeIntfMapperInfo, intf_mapper_info)

    /* Drop Process */
    _sys_at_diag_pkt_tracce_drop_map(lchip,p_rslt,
                                          GetDbgIpeUserIdInfo(V, macsecSopDiscard_f, &user_id_info),
                                          GetDbgIpeUserIdInfo(V, macsecSopDiscardType_f, &user_id_info));
    _sys_at_diag_pkt_tracce_drop_map(lchip,p_rslt,
                                          GetDbgIpeIntfMapperInfo(V, discard_f, &intf_mapper_info),
                                          GetDbgIpeIntfMapperInfo(V, discardType_f, &intf_mapper_info));
    /* Exception Process */
    _sys_at_diag_pkt_tracce_exception_map(lchip,p_rslt,
                                               GetDbgIpeIntfMapperInfo(V, exceptionEn_f, &intf_mapper_info),
                                               GetDbgIpeIntfMapperInfo(V, exceptionIndex_f, &intf_mapper_info),
                                               GetDbgIpeIntfMapperInfo(V, exceptionSubIndex_f, &intf_mapper_info));
    return CTC_E_NONE;
}


STATIC int32
_sys_at_diag_pkt_trace_get_ipe_decap_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
#if (0 == SDK_WORK_PLATFORM)
    uint32 value = 0;
#endif
    char* str[] = {"1st-label-lookup-result", "2nd-label-lookup-result", "3th-label-lookup-result"};
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    DbgMplsHashEngineForLabel0Info_m  label0_info;
    DbgMplsHashEngineForLabel1Info_m  label1_info;
    DbgMplsHashEngineForLabel2Info_m  label2_info;
    DbgIpeMplsDecapInfo_m mpls_decap_info;

    DsMpls_m  ds_mpls;

    sal_memset(&label0_info, 0, sizeof(label0_info));
    cmd = DRV_IOR(DbgMplsHashEngineForLabel0Info_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &label0_info));
    sal_memset(&label1_info, 0, sizeof(label1_info));
    cmd = DRV_IOR(DbgMplsHashEngineForLabel1Info_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &label1_info));
    sal_memset(&label2_info, 0, sizeof(label2_info));
    cmd = DRV_IOR(DbgMplsHashEngineForLabel2Info_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &label2_info));
    sal_memset(&mpls_decap_info, 0, sizeof(mpls_decap_info));
    cmd = DRV_IOR(DbgIpeMplsDecapInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &mpls_decap_info));

    sal_memset(&ds_mpls, 0, sizeof(ds_mpls));

    if (!GetDbgIpeMplsDecapInfo(V, valid_f, &mpls_decap_info))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
    DIAG_INFO_NONE(pos, "Decapsulation")

    if (GetDbgIpeMplsDecapInfo(V, tunnelDecap0_f, &mpls_decap_info)
        || GetDbgIpeMplsDecapInfo(V, tunnelDecap1_f, &mpls_decap_info))
    {
        if (GetDbgIpeMplsDecapInfo(V, innerPacketLookup_f, &mpls_decap_info))
        {
            DIAG_INFO_CHAR(pos, "tunnel-process", "inner-packet-forward")
        }
        else
        {
            DIAG_INFO_CHAR(pos, "tunnel-process", "tunnel-forward")
        }
    }
    else if (GetDbgIpeMplsDecapInfo(V, isMplsSwitched_f, &mpls_decap_info))
    {
        uint8 i = 0;
        uint32 mpls_valid[3] = {
                GetDbgMplsHashEngineForLabel0Info(V, valid_f, &label0_info),
                GetDbgMplsHashEngineForLabel1Info(V, valid_f, &label1_info),
                GetDbgMplsHashEngineForLabel2Info(V, valid_f, &label2_info)};
        uint32 mpls_key_index[3] = {
                GetDbgMplsHashEngineForLabel0Info(V, keyIndex_f, &label0_info),
                GetDbgMplsHashEngineForLabel1Info(V, keyIndex_f, &label1_info),
                GetDbgMplsHashEngineForLabel2Info(V, keyIndex_f, &label2_info)};
        uint32 mpls_ad_index[3] =  {
                GetDbgMplsHashEngineForLabel0Info(V, dsAdIndex_f, &label0_info),
                GetDbgMplsHashEngineForLabel1Info(V, dsAdIndex_f, &label1_info),
                GetDbgMplsHashEngineForLabel2Info(V, dsAdIndex_f, &label2_info)};
        uint32 mpls_conflict[3] = {
                GetDbgMplsHashEngineForLabel0Info(V, mplsHashConflict_f, &label0_info),
                GetDbgMplsHashEngineForLabel1Info(V, mplsHashConflict_f, &label1_info),
                GetDbgMplsHashEngineForLabel2Info(V, mplsHashConflict_f, &label2_info)};
        uint32 mpls_result_valid[3] = {
                GetDbgMplsHashEngineForLabel0Info(V, lookupResultValid_f, &label0_info),
                GetDbgMplsHashEngineForLabel1Info(V, lookupResultValid_f, &label1_info),
                GetDbgMplsHashEngineForLabel2Info(V, lookupResultValid_f, &label2_info)};
        uint32 mpls_result_cam_valid[3] = {
                GetDbgMplsHashEngineForLabel0Info(V, camLookupResultValid_f, &label0_info),
                GetDbgMplsHashEngineForLabel1Info(V, camLookupResultValid_f, &label1_info),
                GetDbgMplsHashEngineForLabel2Info(V, camLookupResultValid_f, &label2_info)};

        for (i = 0; i < 3; i++)
        {
            if (mpls_valid[i])
            {
                if (GetDbgIpeMplsDecapInfo(V, innerPacketLookup_f, &mpls_decap_info))
                {
                    DIAG_INFO_CHAR(pos, "mpls-process", "inner-packet-forward")
                }
                else
                {
                    DIAG_INFO_CHAR(pos, "mpls-process", "mpls-label-forward")
                }
                if (mpls_conflict[i])
                {
                    DIAG_INFO_CHAR(pos, str[i], DIAG_LOOKUP_CONFLICT)
                    DIAG_INFO_CHAR(pos, "is-cam-hit", mpls_result_cam_valid[i] ? DIAG_YES : DIAG_NO)
                    DIAG_INFO_CHAR(pos, "key-name", "DsMplsLabelHashKey")
                    DIAG_INFO_UINT32(pos, "key-index", mpls_key_index[i])
                }
                else if (mpls_result_valid[i])
                {
                    DIAG_INFO_CHAR(pos, str[i], DIAG_LOOKUP_HIT)
                    DIAG_INFO_CHAR(pos, "is-cam-hit", mpls_result_cam_valid[i] ? DIAG_YES : DIAG_NO)
                    DIAG_INFO_CHAR(pos, "key-name", "DsMplsLabelHashKey")
                    #if (0 == SDK_WORK_PLATFORM)
                    value = DRV_TABLE_MAX_INDEX(lchip, DsMplsHashCam_t);
                    DIAG_INFO_UINT32(pos, "key-index", (mpls_key_index[i]+value))
                    #endif
                    #if (1 == SDK_WORK_PLATFORM)
                    DIAG_INFO_UINT32(pos, "key-index", (mpls_key_index[i]))
                    #endif
                    DIAG_INFO_CHAR(pos, "ad-name",  "DsMpls")
                    //DIAG_INFO_CHAR(pos, "ad-name", ((mpls_key_index[i] < value) ? "DsMplsHashCamAd" : "DsMpls"))
                    DIAG_INFO_UINT32(pos, "ad-index", mpls_ad_index[i])
                    DIAG_INFO_CHAR(pos, "pop-lable", "YES")
                    DIAG_INFO_XDATA_PROF2(pos,mpls_ad_index[i],GetDsMpls,DsMpls_t,ds_mpls)
                }
                else
                {
                    DIAG_INFO_CHAR(pos, str[i], DIAG_LOOKUP_HIT_NONE)
                }

            }
        }
    }

    if (GetDbgIpeMplsDecapInfo(V, policerValid0_f, &mpls_decap_info))
    {
        DIAG_INFO_UINT32(pos, "policer-ptr-0", GetDbgIpeMplsDecapInfo(V, policerPtr0_f, &mpls_decap_info))
    }
    if (GetDbgIpeMplsDecapInfo(V, policerValid1_f, &mpls_decap_info))
    {
        DIAG_INFO_UINT32(pos, "policer-ptr-1", GetDbgIpeMplsDecapInfo(V, policerPtr1_f, &mpls_decap_info))
    }

    DIAG_INFO_XDATA(pos, GetDbgIpeMplsDecapInfo, mpls_decap_info)

    /* Drop Process */
    _sys_at_diag_pkt_tracce_drop_map(lchip,p_rslt,
                                          GetDbgIpeMplsDecapInfo(V, discard_f, &mpls_decap_info),
                                          GetDbgIpeMplsDecapInfo(V, discardType_f, &mpls_decap_info));
    /* Exception Process */
    _sys_at_diag_pkt_tracce_exception_map(lchip,p_rslt,
                                               GetDbgIpeMplsDecapInfo(V, exceptionEn_f, &mpls_decap_info),
                                               GetDbgIpeMplsDecapInfo(V, exceptionIndex_f, &mpls_decap_info),
                                               GetDbgIpeMplsDecapInfo(V, exceptionSubIndex_f, &mpls_decap_info));

    return CTC_E_NONE;
}
STATIC int32
_sys_at_diag_pkt_trace_get_lkup_mgr_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint32 value = 0;
    uint32 data[4] = {0};
    uint32 data_temp[4] = {0};
    uint8  pos = CTC_DIAG_TRACE_POS_IPE;
    uint8  decode_print_valid = 0;
    uint8  loop = 0;
    uint8  step = DbgProgramLtidTcamEngineAclInfoIgr_gAclLookup_1_lookupEn_f - DbgProgramLtidTcamEngineAclInfoIgr_gAclLookup_0_lookupEn_f;
    hw_mac_addr_t hw_mac = {0};
    DbgIpeLkpMgrInfo_m lkp_mgr_info;
    DbgFibLkpEngineMacSaHashInfo_m macsa_info;
    DbgFibLkpEngineTcamKeyInfo_m dbg_tcam_key;
/*    DbgFibLkpEngineHostUrpfHashInfo_m  urpf_info;*/
    DbgFibLkpEngineMacDaHashInfo_m  macda_info;
    DbgFibLkpEngineL3DaHashInfo_m   l3da_info;
    DbgFibLkpEngineL3SaHashInfo_m   l3sa_info;
    DbgProgramLtidTcamEngineAclInfoIgr_m ltid_info;
    union
    {
        DbgIpeLookupManagerUdfDecoder_m udf_decoder;
        DbgIpeLookupManagerOuterL2Decoder_m outer_l2_decoder;
        DbgIpeLookupManagerOuterL3Decoder_m outer_l3_decoder;
        DbgIpeLookupManagerOuterL4Decoder_m outer_l4_decoder;
        DbgIpeLookupManagerInnerL2Decoder_m inner_l2_decoder;
        DbgIpeLookupManagerInnerL3Decoder_m inner_l3_decoder;
        DbgIpeLookupManagerInnerL4Decoder_m inner_l4_decoder;
    } un;
    EfdDebugStats_m efd_dbg_stats;
    void* ds = (void*)&un.udf_decoder;


    sal_memset(&lkp_mgr_info, 0, sizeof(lkp_mgr_info));
    cmd = DRV_IOR(DbgIpeLkpMgrInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &lkp_mgr_info));

    if (!GetDbgIpeLkpMgrInfo(V, valid_f, &lkp_mgr_info))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
    DIAG_INFO_NONE(pos, "Lookup Manager")

    cmd = DRV_IOR(DbgProgramLtidTcamEngineAclInfoIgr_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &ltid_info));
    for (loop=0; loop<DIAG_IGS_ACL_LKUP_NUM; loop++)
    {
        cmd = DRV_IOR(DbgProgramAclTcamEngineAclInfoIgr0_t+loop, DbgProgramAclTcamEngineAclInfoIgr0_hit_f);
        CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
        decode_print_valid = decode_print_valid || (!value && GetDbgProgramLtidTcamEngineAclInfoIgr(V, gAclLookup_0_lookupEn_f + step*loop, &ltid_info));
    }

    cmd = DRV_IOR(DbgIpeLookupManagerUdfDecoder0_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), ds));
    if (GetDbgIpeLookupManagerUdfDecoder(V, valid_f, ds))
    {
        DIAG_INFO_NONE(pos, "--UDF Decoder")
        if (0 != GetDbgIpeLookupManagerUdfDecoder(V, udfValid_f, ds))
        {
            sys_acl_udf_info_t udf_info = {0};
            uint16 udf_ad_id = GetDbgIpeLookupManagerUdfDecoder(V, udfHitIndex_f, ds);

            DIAG_INFO_CHAR(pos, "udf-lkup", DIAG_LOOKUP_HIT)
            DIAG_INFO_CHAR(pos, "xlookup", GetDbgIpeLookupManagerUdfDecoder(V, xLookupUdfEn_f, ds) ? DIAG_ENABLE : DIAG_DISABLE)

            value = GetDbgIpeLkpMgrInfo(V, udfHitIndex_f, &lkp_mgr_info);
            DIAG_INFO_UINT32(pos, "key-index", value)
            DIAG_INFO_UINT32(pos, "udf-ad-id", udf_ad_id)

            GetDbgIpeLookupManagerUdfDecoder(A, udf_f, ds, data);
            sys_usw_acl_get_udf_info_by_ad_id(lchip, udf_ad_id, &udf_info);
            DIAG_SET_USR_UDF(udf_info.granularity, data_temp, data);
            DIAG_INFO_UDF(pos, "udf-data", data_temp);
            DIAG_INFO_CHAR(pos, "acl-xad-use-udf", GetDbgIpeLookupManagerUdfDecoder(V, aclUdfEn_f, ds) ? DIAG_YES : DIAG_NO)
            DIAG_INFO_CHAR(pos, "xhash-use-udf", GetDbgIpeLookupManagerUdfDecoder(V, flowDigestUdfEn_f, ds) ? DIAG_YES : DIAG_NO)
            DIAG_INFO_CHAR(pos, "xlookup-use-udf", GetDbgIpeLookupManagerUdfDecoder(V, xLookupUdfEn_f, ds) ? DIAG_YES : DIAG_NO)
        }
        else
        {
            DIAG_INFO_CHAR(pos, "udf-lkup", DIAG_LOOKUP_HIT_NONE)
        }

    }

    cmd = DRV_IOR(DbgIpeLookupManagerUdfDecoder_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), ds));
    if (GetDbgIpeLookupManagerUdfDecoder(V, valid_f, ds))
    {
        DIAG_INFO_NONE(pos, "--SUDF Decoder")
        if (0 != GetDbgIpeLookupManagerUdfDecoder(V, udfValid_f, ds))
        {
            sys_acl_udf_info_t udf_info = {0};
            uint16 udf_ad_id = GetDbgIpeLookupManagerUdfDecoder(V, udfHitIndex_f, ds);

            DIAG_INFO_CHAR(pos, "udf-lkup", DIAG_LOOKUP_HIT)
            DIAG_INFO_CHAR(pos, "xlookup", GetDbgIpeLookupManagerUdfDecoder(V, xLookupUdfEn_f, ds) ? DIAG_ENABLE : DIAG_DISABLE)

            value = GetDbgIpeLkpMgrInfo(V, flowUdfHitIndex_f, &lkp_mgr_info);
            DIAG_INFO_UINT32(pos, "ad-index", value)
            DIAG_INFO_UINT32(pos, "udf-ad-id", udf_ad_id)

            GetDbgIpeLookupManagerUdfDecoder(A, udf_f, ds, data);
            sys_usw_acl_get_udf_info_by_ad_id(lchip, udf_ad_id, &udf_info);
            DIAG_SET_USR_UDF(udf_info.granularity, data_temp, data);
            DIAG_INFO_UDF(pos, "udf-data", data_temp);
            DIAG_INFO_CHAR(pos, "acl-xad-use-udf", GetDbgIpeLookupManagerUdfDecoder(V, aclUdfEn_f, ds) ? DIAG_YES : DIAG_NO)
            DIAG_INFO_CHAR(pos, "xhash-use-udf", GetDbgIpeLookupManagerUdfDecoder(V, flowDigestUdfEn_f, ds) ? DIAG_YES : DIAG_NO)
            DIAG_INFO_CHAR(pos, "xlookup-use-udf", GetDbgIpeLookupManagerUdfDecoder(V, xLookupUdfEn_f, ds) ? DIAG_YES : DIAG_NO)
        }
        else
        {
            DIAG_INFO_CHAR(pos, "udf-lkup", DIAG_LOOKUP_HIT_NONE)
        }
    }

    cmd = DRV_IOR(DbgIpeLookupManagerOuterL2Decoder_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), ds));
    if (GetDbgIpeLookupManagerOuterL2Decoder(V, valid_f, ds) && decode_print_valid)
    {
        DIAG_INFO_NONE(pos, "--Outer L2 Decoder")
        GetDbgIpeLookupManagerOuterL2Decoder(A, macDa_f, ds, data);
        DIAG_INFO_MAC(pos, "outer-mac-da", data)
        GetDbgIpeLookupManagerOuterL2Decoder(A, macSa_f, ds, data);
        DIAG_INFO_MAC(pos, "outer-mac-sa", data)
        DIAG_INFO_U32_HEX(pos, "outer-ether-type", GetDbgIpeLookupManagerOuterL2Decoder(V, etherType_f, ds))
        value = GetDbgIpeLookupManagerOuterL2Decoder(V, svlanTag_f, ds);
        DIAG_INFO_UINT32(pos, "outer-svlan-id", DIAG_DECODE_VLAN_ID(value))
        DIAG_INFO_UINT32(pos, "outer-scos", DIAG_DECODE_VLAN_COS(value))
        DIAG_INFO_UINT32(pos, "outer-scfi", DIAG_DECODE_VLAN_CFI(value))
        value = GetDbgIpeLookupManagerOuterL2Decoder(V, cvlanTag_f, ds);
        DIAG_INFO_UINT32(pos, "outer-cvlan-id", DIAG_DECODE_VLAN_ID(value))
        DIAG_INFO_UINT32(pos, "outer-ccos", DIAG_DECODE_VLAN_COS(value))
        DIAG_INFO_UINT32(pos, "outer-ccfi", DIAG_DECODE_VLAN_CFI(value))
        DIAG_INFO_U32_HEX(pos, "outer-data0", GetDbgIpeLookupManagerOuterL2Decoder(V, data0_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data1", GetDbgIpeLookupManagerOuterL2Decoder(V, data1_f, ds))
    }
    cmd = DRV_IOR(DbgIpeLookupManagerOuterL3Decoder_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), ds));
    if (GetDbgIpeLookupManagerOuterL3Decoder(V, valid_f, ds) && decode_print_valid)
    {
        DIAG_INFO_NONE(pos, "--Outer L3 Decoder")
        DIAG_INFO_U32_HEX(pos, "outer-data0", GetDbgIpeLookupManagerOuterL3Decoder(V, uF0_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data1", GetDbgIpeLookupManagerOuterL3Decoder(V, uF1_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data2", GetDbgIpeLookupManagerOuterL3Decoder(V, uF2_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data3", GetDbgIpeLookupManagerOuterL3Decoder(V, uF3_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data4", GetDbgIpeLookupManagerOuterL3Decoder(V, uF4_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data5", GetDbgIpeLookupManagerOuterL3Decoder(V, uF5_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data6", GetDbgIpeLookupManagerOuterL3Decoder(V, uF6_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data7", GetDbgIpeLookupManagerOuterL3Decoder(V, uF7_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data8", GetDbgIpeLookupManagerOuterL3Decoder(V, uF8_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data9", GetDbgIpeLookupManagerOuterL3Decoder(V, uF9_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data10", GetDbgIpeLookupManagerOuterL3Decoder(V, uF10_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data11", GetDbgIpeLookupManagerOuterL3Decoder(V, uF11_gField_data_f, ds))
    }
    cmd = DRV_IOR(DbgIpeLookupManagerOuterL4Decoder_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), ds));
    if (GetDbgIpeLookupManagerOuterL4Decoder(V, valid_f, ds) && decode_print_valid)
    {
        DIAG_INFO_NONE(pos, "--Outer L4 Decoder")
        DIAG_INFO_U32_HEX(pos, "outer-data0", GetDbgIpeLookupManagerOuterL4Decoder(V, uF0_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data1", GetDbgIpeLookupManagerOuterL4Decoder(V, uF1_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data2", GetDbgIpeLookupManagerOuterL4Decoder(V, uF2_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data3", GetDbgIpeLookupManagerOuterL4Decoder(V, uF3_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data4", GetDbgIpeLookupManagerOuterL4Decoder(V, uF4_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data5", GetDbgIpeLookupManagerOuterL4Decoder(V, uF5_gField_data_f, ds))
    }
    cmd = DRV_IOR(DbgIpeMplsDecapInfo_t, DbgIpeMplsDecapInfo_secondParserEn_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &value));
    if (value != 0 && decode_print_valid)
    {
        cmd = DRV_IOR(DbgIpeLookupManagerInnerL2Decoder_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), ds));
        if (GetDbgIpeLookupManagerInnerL2Decoder(V, valid_f, ds))
        {
            DIAG_INFO_NONE(pos, "--Inner L2 Decoder")
            GetDbgIpeLookupManagerInnerL2Decoder(A, macDa_f, ds, data);
            DIAG_INFO_MAC(pos, "Inner-mac-da", data)
            GetDbgIpeLookupManagerInnerL2Decoder(A, macSa_f, ds, data);
            DIAG_INFO_MAC(pos, "Inner-mac-sa", data)
            DIAG_INFO_U32_HEX(pos, "Inner-ether-type", GetDbgIpeLookupManagerInnerL2Decoder(V, etherType_f, ds))
            value = GetDbgIpeLookupManagerInnerL2Decoder(V, svlanTag_f, ds);
            DIAG_INFO_UINT32(pos, "Inner-svlan-id", DIAG_DECODE_VLAN_ID(value))
            DIAG_INFO_UINT32(pos, "Inner-scos", DIAG_DECODE_VLAN_COS(value))
            DIAG_INFO_UINT32(pos, "Inner-scfi", DIAG_DECODE_VLAN_CFI(value))
            value = GetDbgIpeLookupManagerInnerL2Decoder(V, cvlanTag_f, ds);
            DIAG_INFO_UINT32(pos, "Inner-cvlan-id", DIAG_DECODE_VLAN_ID(value))
            DIAG_INFO_UINT32(pos, "Inner-ccos", DIAG_DECODE_VLAN_COS(value))
            DIAG_INFO_UINT32(pos, "Inner-ccfi", DIAG_DECODE_VLAN_CFI(value))
            DIAG_INFO_U32_HEX(pos, "Inner-data0", GetDbgIpeLookupManagerInnerL2Decoder(V, data0_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data1", GetDbgIpeLookupManagerInnerL2Decoder(V, data1_f, ds))
        }
        cmd = DRV_IOR(DbgIpeLookupManagerInnerL3Decoder_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), ds));
        if (GetDbgIpeLookupManagerInnerL3Decoder(V, valid_f, ds))
        {
            DIAG_INFO_NONE(pos, "--Inner L3 Decoder")
            DIAG_INFO_U32_HEX(pos, "Inner-data0", GetDbgIpeLookupManagerInnerL3Decoder(V, uF0_gField_data_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data1", GetDbgIpeLookupManagerInnerL3Decoder(V, uF1_gField_data_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data2", GetDbgIpeLookupManagerInnerL3Decoder(V, uF2_gField_data_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data3", GetDbgIpeLookupManagerInnerL3Decoder(V, uF3_gField_data_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data4", GetDbgIpeLookupManagerInnerL3Decoder(V, uF4_gField_data_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data5", GetDbgIpeLookupManagerInnerL3Decoder(V, uF5_gField_data_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data6", GetDbgIpeLookupManagerInnerL3Decoder(V, uF6_gField_data_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data7", GetDbgIpeLookupManagerInnerL3Decoder(V, uF7_gField_data_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data8", GetDbgIpeLookupManagerInnerL3Decoder(V, uF8_gField_data_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data9", GetDbgIpeLookupManagerInnerL3Decoder(V, uF9_gField_data_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data10", GetDbgIpeLookupManagerInnerL3Decoder(V, uF10_gField_data_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data11", GetDbgIpeLookupManagerInnerL3Decoder(V, uF11_gField_data_f, ds))
        }
        cmd = DRV_IOR(DbgIpeLookupManagerInnerL4Decoder_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), ds));
        if (GetDbgIpeLookupManagerInnerL4Decoder(V, valid_f, ds))
        {
            DIAG_INFO_NONE(pos, "--Inner L4 Decoder")
            DIAG_INFO_U32_HEX(pos, "Inner-data0", GetDbgIpeLookupManagerInnerL4Decoder(V, uF0_gField_data_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data1", GetDbgIpeLookupManagerInnerL4Decoder(V, uF1_gField_data_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data2", GetDbgIpeLookupManagerInnerL4Decoder(V, uF2_gField_data_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data3", GetDbgIpeLookupManagerInnerL4Decoder(V, uF3_gField_data_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data4", GetDbgIpeLookupManagerInnerL4Decoder(V, uF4_gField_data_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data5", GetDbgIpeLookupManagerInnerL4Decoder(V, uF5_gField_data_f, ds))
        }
    }
    if (GetDbgIpeLkpMgrInfo(V, isInnerMacSaLookup_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "inner-macsa-lookup", "TRUE")
    }
    if (GetDbgIpeLkpMgrInfo(V, efdEnable_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "elephant-detect", "ENABLE")
    }
    if (GetDbgIpeLkpMgrInfo(V, isElephant_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "elephant-flow", "TURE")
    }
    if (GetDbgIpeLkpMgrInfo(V, isNewElephant_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "new-elephant-flow", "TURE")
    }
    if (GetDbgIpeLkpMgrInfo(V, isIpv4Ucast_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "packet-type", "IPv4-UC")
    }
    if (GetDbgIpeLkpMgrInfo(V, isIpv4Mcast_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "packet-type", "IPv4-MC")
    }
    if (GetDbgIpeLkpMgrInfo(V, isIpv4UcastNat_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "packet-type", "IPv4-UC-NAT")
    }
    if (GetDbgIpeLkpMgrInfo(V, isIpv4UcastRpf_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "packet-type", "IPv4-UC-RPF")
    }
    if (GetDbgIpeLkpMgrInfo(V, isIpv6Ucast_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "packet-type", "IPv6-UC")
    }
    if (GetDbgIpeLkpMgrInfo(V, isIpv6Mcast_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "packet-type", "IPv6-MC")
    }
    if (GetDbgIpeLkpMgrInfo(V, isIpv6UcastNat_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "packet-type", "IPv6-UC-NAT")
    }
    if (GetDbgIpeLkpMgrInfo(V, isIpv6UcastRpf_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "packet-type", "IPv6-UC-RPF")
    }
    if (GetDbgIpeLkpMgrInfo(V, isIpv4IcmpErrMsg_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "packet-type", "IPv4-ICMP-ERROR-MSG")
    }
    if (GetDbgIpeLkpMgrInfo(V, isIpv6IcmpErrMsg_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "packet-type", "IPv6-ICMP-ERROR-MSG")
    }
    if (GetDbgIpeLkpMgrInfo(V, isTrillUcast_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "packet-type", "TRILL-UC")
    }
    if (GetDbgIpeLkpMgrInfo(V, isTrillMcast_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "packet-type", "TRILL-MC")
    }
    if (GetDbgIpeLkpMgrInfo(V, isFcoe_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "packet-type", "FCoE")
    }
    if (GetDbgIpeLkpMgrInfo(V, isFcoeRpf_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "packet-type", "FCoE-RPF")
    }
    if (GetDbgIpeLkpMgrInfo(V, ipv4McastAddressCheckFailure_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "ipv4mc-addr-check", "FAILURE")
    }
    if (GetDbgIpeLkpMgrInfo(V, ipv6McastAddressCheckFailure_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "ipv6mc-addr-check", "FAILURE")
    }

    sal_memset(&macda_info, 0, sizeof(macda_info));
    cmd = DRV_IOR(DbgFibLkpEngineMacDaHashInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &macda_info));
    if (GetDbgFibLkpEngineMacDaHashInfo(V, valid_f, &macda_info)
        && GetDbgFibLkpEngineMacDaHashInfo(V, gMacDaLkp_macDaLookupEn_f, &macda_info))
    {
        GetDbgFibLkpEngineMacDaHashInfo(A, gMacDaLkp_mappedMac_f, &macda_info, hw_mac);
        /*mac da lookup key*/
        DIAG_INFO_CHAR(pos, "macda-lookup", "ENABLE")
        DIAG_INFO_MAC(pos, "key-macda", hw_mac)
        DIAG_INFO_UINT32(pos, "key-fid", GetDbgFibLkpEngineMacDaHashInfo(V, gMacDaLkp_vsiId_f, &macda_info))
    }

    sal_memset(&macsa_info, 0, sizeof(macsa_info));
    cmd = DRV_IOR(DbgFibLkpEngineMacSaHashInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &macsa_info));
    if (GetDbgFibLkpEngineMacSaHashInfo(V, valid_f, &macsa_info)
        && GetDbgFibLkpEngineMacSaHashInfo(V, gMacSaLkp_macSaLookupEn_f, &macsa_info))
    {
        /*mac sa lookup key*/
        GetDbgFibLkpEngineMacSaHashInfo(A, gMacSaLkp_mappedMac_f, &macsa_info, hw_mac);
        DIAG_INFO_CHAR(pos, "macsa-lookup", "ENABLE")
        DIAG_INFO_MAC(pos, "key-macsa", hw_mac)
        DIAG_INFO_UINT32(pos, "key-fid", GetDbgFibLkpEngineMacSaHashInfo(V, gMacSaLkp_vsiId_f, &macsa_info))
    }

    sal_memset(&l3da_info, 0, sizeof(l3da_info));
    cmd = DRV_IOR(DbgFibLkpEngineL3DaHashInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &l3da_info));
    if (GetDbgFibLkpEngineL3DaHashInfo(V, valid_f, &l3da_info)
        && GetDbgFibLkpEngineL3DaHashInfo(V, l3DaLookupEn_f, &l3da_info))
    {
        /*l3 da lookup key*/
        int32 ret = 0;
        drv_acc_in_t acc_in;
        drv_acc_out_t acc_out;
        char* str_l3da[] = {"IPv4-UCAST", "IPv6-UCAST", "IPv4-MCAST",
                            "IPv6-MCAST", "FCoE", "TRILL-UCAST", "TRILL-MCAST", "RESERVED"};
        DIAG_INFO_CHAR(pos, "l3da-lookup", "ENABLE")
        value = GetDbgFibLkpEngineL3DaHashInfo(V, l3DaKeyType_f, &l3da_info);
        DIAG_INFO_CHAR(pos, "l3da-lkup-key-type", str_l3da[value])

        sal_memset(&acc_in, 0, sizeof(acc_in));
        sal_memset(&acc_out, 0, sizeof(acc_out));
        switch (value)
        {
            case SYS_AT_DIAG_L3DA_TYPE_IPV4UC:
                /*DsFibHost0Ipv4HashKey_t*/
                break;
            case SYS_AT_DIAG_L3DA_TYPE_IPV6UC:
                /*DsFibHost0Ipv6UcastHashKey_t*/
                break;
            case SYS_AT_DIAG_L3DA_TYPE_IPV4MC:
                /*DsFibHost0Ipv4HashKey_t*/
                break;
            case SYS_AT_DIAG_L3DA_TYPE_IPV6MC:
                /*DsFibHost0MacIpv6McastHashKey_t*/
                break;
            case SYS_AT_DIAG_L3DA_TYPE_TRILLUC:
                acc_in.index = GetDbgFibLkpEngineL3DaHashInfo(V, hostHashFirstL3DaKeyIndex_f, &l3da_info);
                acc_in.type = DRV_ACC_TYPE_LOOKUP;
                acc_in.tbl_id = DsFibHost0TrillHashKey_t;
                acc_in.op_type = DRV_ACC_OP_BY_INDEX;
                drv_acc_get_hash_module(lchip, acc_in.tbl_id, &acc_in.module);
                ret = drv_acc_api(lchip, &acc_in, &acc_out);
                if (ret == 0)
                {
                    DIAG_INFO_U32_HEX(pos, "key-egs-nickname", GetDsFibHost0TrillHashKey(V, egressNickname_f, acc_out.data))
                }
                break;
            case SYS_AT_DIAG_L3DA_TYPE_TRILLMC:
                acc_in.index = GetDbgFibLkpEngineL3DaHashInfo(V, hostHashFirstL3DaKeyIndex_f, &l3da_info);
                acc_in.type = DRV_ACC_TYPE_LOOKUP;
                acc_in.tbl_id = DsFibHost1TrillMcastVlanHashKey_t;
                acc_in.op_type = DRV_ACC_OP_BY_INDEX;
                drv_acc_get_hash_module(lchip, acc_in.tbl_id, &acc_in.module);
                ret = drv_acc_api(lchip, &acc_in, &acc_out);
                if (ret == 0)
                {
                    DIAG_INFO_U32_HEX(pos, "key-egs-nickname", GetDsFibHost1TrillMcastVlanHashKey(V, egressNickname_f, acc_out.data))
                    DIAG_INFO_U32_HEX(pos, "key-vlan-id", GetDsFibHost1TrillMcastVlanHashKey(V, vlanId_f, acc_out.data))
                }
                break;
            case SYS_AT_DIAG_L3DA_TYPE_FCOE:
                acc_in.index = GetDbgFibLkpEngineL3DaHashInfo(V, hostHashFirstL3DaKeyIndex_f, &l3da_info);
                acc_in.type = DRV_ACC_TYPE_LOOKUP;
                acc_in.tbl_id = DsFibHost0FcoeHashKey_t;
                acc_in.op_type = DRV_ACC_OP_BY_INDEX;
                drv_acc_get_hash_module(lchip, acc_in.tbl_id, &acc_in.module);
                ret = drv_acc_api(lchip, &acc_in, &acc_out);
                if (ret == 0)
                {
                    DIAG_INFO_U32_HEX(pos, "key-fcid", GetDsFibHost0FcoeHashKey(V, fcoeDid_f, acc_out.data))
                    DIAG_INFO_U32_HEX(pos, "key-fid", GetDsFibHost0FcoeHashKey(V, vsiId_f, acc_out.data))
                }
                break;
            default:
                break;
        }
    }

    sal_memset(&l3sa_info, 0, sizeof(l3sa_info));
    cmd = DRV_IOR(DbgFibLkpEngineL3SaHashInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &l3sa_info));
    if (GetDbgFibLkpEngineL3SaHashInfo(V, valid_f, &l3sa_info)
        && GetDbgFibLkpEngineL3SaHashInfo(V, l3SaLookupEn_f, &l3sa_info))
    {

        char* str_l3sa[] = {"IPv4-RPF", "IPv6-RPF", "IPv4-PBR",
                            "IPv6-PBR", "IPv4-NATSA", "IPv6-NATSA", "FCoE-RPF"};
        /*l3 da lookup key*/
        DIAG_INFO_CHAR(pos, "l3sa-lookup", "ENABLE")
        value = GetDbgFibLkpEngineL3SaHashInfo(V, l3SaKeyType_f, &l3sa_info);
        DIAG_INFO_CHAR(pos, "l3sa-lkup-key-type", str_l3sa[value])
    }

    cmd = DRV_IOR(DbgFibLkpEngineTcamKeyInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &dbg_tcam_key));
    if (GetDbgFibLkpEngineTcamKeyInfo(V, valid_f, &dbg_tcam_key))
    {
        uint32 value_array[6] = {0};
        uint8 hit = 0;
        if (GetDbgFibLkpEngineTcamKeyInfo(V, dbgFromNatDaLookup_f, &dbg_tcam_key))
        {
            DIAG_INFO_CHAR(pos, "natda-lookup", "ENABLE")
            GetDbgFibLkpEngineTcamKeyInfo(A, dbgNatDaHashKey_f, &dbg_tcam_key, value_array);
            DIAG_INFO_U32_LIST(pos, "natda-key", value_array, 6)
            if (GetDbgFibLkpEngineTcamKeyInfo(V, l3NatDaTcamResultValid_f, &dbg_tcam_key))
            {
                DIAG_INFO_CHAR(pos, "natda-tcam-lookup", "HIT")
                DIAG_INFO_UINT32(pos, "natda-tcam-index", GetDbgFibLkpEngineTcamKeyInfo(V, l3NatDaResultTcamEntryIndex_f, &dbg_tcam_key))
            }
            else
            {
                DIAG_INFO_CHAR(pos, "natda-tcam-lookup", "HIT-NONE")
            }

        }

        if (GetDbgFibLkpEngineTcamKeyInfo(V, dbgFromNatSaLookup_f, &dbg_tcam_key))
        {
            DIAG_INFO_CHAR(pos, "natsa-lookup", "ENABLE")
            GetDbgFibLkpEngineTcamKeyInfo(A, dbgNatSaHashKey_f, &dbg_tcam_key, value_array);
            DIAG_INFO_U32_LIST(pos, "natsa-key", value_array, 6)
            if (GetDbgFibLkpEngineTcamKeyInfo(V, l3NatSaTcamResultValid_f, &dbg_tcam_key))
            {
                DIAG_INFO_CHAR(pos, "natsa-tcam-lookup", "HIT")
                DIAG_INFO_UINT32(pos, "natsa-tcam-index", GetDbgFibLkpEngineTcamKeyInfo(V, l3NatSaResultTcamEntryIndex_f, &dbg_tcam_key))
            }
            else
            {
                DIAG_INFO_CHAR(pos, "natsa-tcam-lookup", "HIT-NONE")
            }
        }
        if ((GetDbgFibLkpEngineL3DaHashInfo(V, valid_f, &l3da_info)
        && GetDbgFibLkpEngineL3DaHashInfo(V, l3DaLookupEn_f, &l3da_info)))
        {
            GetDbgFibLkpEngineTcamKeyInfo(A, dbgLpmDaHashKey_f, &dbg_tcam_key, value_array);
            DIAG_INFO_U32_LIST(pos, "lpmda-tcam-key", value_array, 6)
            if (GetDbgFibLkpEngineTcamKeyInfo(V, lpmDaPrivate1ResultValid_f, &dbg_tcam_key))
            {
                DIAG_INFO_CHAR(pos, "lpmda-private1-lookup", "HIT")
                DIAG_INFO_UINT32(pos, "tcam-hit-index", GetDbgFibLkpEngineTcamKeyInfo(V, lpmDaPrivate1TcamHitIndex_f, &dbg_tcam_key))
                hit = 1;
            }
            if (GetDbgFibLkpEngineTcamKeyInfo(V, lpmDaPublic1ResultValid_f, &dbg_tcam_key))
            {
                DIAG_INFO_CHAR(pos, "lpmda-public1-lookup", "HIT")
                DIAG_INFO_UINT32(pos, "tcam-hit-index", GetDbgFibLkpEngineTcamKeyInfo(V, lpmDaPublic1TcamHitIndex_f, &dbg_tcam_key))
                hit = 1;
            }
            if (!hit)
            {
                DIAG_INFO_CHAR(pos, "lpmda-tcam-lookup", "HIT-NONE")
            }
        }
        if ((GetDbgFibLkpEngineL3SaHashInfo(V, valid_f, &l3sa_info)
        && GetDbgFibLkpEngineL3SaHashInfo(V, l3SaLookupEn_f, &l3sa_info)))
        {
            hit = 0;
            GetDbgFibLkpEngineTcamKeyInfo(A, dbgLpmDaHashKey_f, &dbg_tcam_key, value_array);
            DIAG_INFO_U32_LIST(pos, "lpmsa-tcam-key", value_array, 6)
            if (GetDbgFibLkpEngineTcamKeyInfo(V, lpmSaPrivate1ResultValid_f, &dbg_tcam_key))
            {
                DIAG_INFO_CHAR(pos, "lpmsa-private1-lookup", "HIT")
                DIAG_INFO_UINT32(pos, "tcam-hit-index", GetDbgFibLkpEngineTcamKeyInfo(V, lpmSaPrivate1TcamHitIndex_f, &dbg_tcam_key))
                hit = 1;
            }
            if (GetDbgFibLkpEngineTcamKeyInfo(V, lpmSaPublic1ResultValid_f, &dbg_tcam_key))
            {
                DIAG_INFO_CHAR(pos, "lpmsa-public1-lookup", "HIT")
                DIAG_INFO_UINT32(pos, "tcam-hit-index", GetDbgFibLkpEngineTcamKeyInfo(V, lpmSaPublic1TcamHitIndex_f, &dbg_tcam_key))
                hit = 1;
            }
            if (!hit)
            {
                DIAG_INFO_CHAR(pos, "lpmsa-tcam-lookup", "HIT-NONE")
            }
        }
    }

    cmd = DRV_IOR(EfdDebugStats_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &efd_dbg_stats));
    DIAG_INFO_UINT32(pos, "efd-aging-cnt", GetEfdDebugStats(V, agingCnt_f, &efd_dbg_stats))
    DIAG_INFO_UINT32(pos, "efd-detect-cnt", GetEfdDebugStats(V, detectCnt_f, &efd_dbg_stats))
    DIAG_INFO_UINT32(pos, "efd-cpu-access-cnt", GetEfdDebugStats(V, cpuAccessCnt_f, &efd_dbg_stats))
    DIAG_INFO_UINT32(pos, "efd-insert-cnt", GetEfdDebugStats(V, insertCnt_f, &efd_dbg_stats))
    DIAG_INFO_UINT32(pos, "efd-update-cnt", GetEfdDebugStats(V, updateCnt_f, &efd_dbg_stats))
    DIAG_INFO_UINT32(pos, "efd-hash-conflict-cnt", GetEfdDebugStats(V, hashConflictCnt_f, &efd_dbg_stats))

    DIAG_INFO_XDATA(pos, GetDbgIpeLkpMgrInfo, lkp_mgr_info)

    /* Drop Process */
    _sys_at_diag_pkt_tracce_drop_map(lchip,p_rslt,
                                          GetDbgIpeLkpMgrInfo(V, discard_f, &lkp_mgr_info),
                                          GetDbgIpeLkpMgrInfo(V, discardType_f, &lkp_mgr_info));
    /* Exception Process */
    _sys_at_diag_pkt_tracce_exception_map(lchip,p_rslt,
                                               GetDbgIpeLkpMgrInfo(V, exceptionEn_f, &lkp_mgr_info),
                                               GetDbgIpeLkpMgrInfo(V, exceptionIndex_f, &lkp_mgr_info),
                                               GetDbgIpeLkpMgrInfo(V, exceptionSubIndex_f, &lkp_mgr_info));
    return CTC_E_NONE;
}

STATIC int32
_sys_at_diag_pkt_trace_get_flow_hash_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint32 value = 0;
    uint32 value1 = 0;
    uint32 data_buf0[2] = {0};
    uint32 data_buf1[2] = {0};
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    char*  str_hash_key_name[] = {"Invalid", "DsFlowL2HashKey", "DsFlowL2L3HashKey", "DsFlowL3Ipv4HashKey",
                                    "DsFlowL3Ipv6HashKey", "DsFlowL3MplsHashKey", "Reserved", "DsFlowNshHashKey"};
    char*  str_field_sel_name[] = {"Invalid", "FlowL2HashFieldSelect", "FlowL2L3HashFieldSelect", "FlowL3Ipv4HashFieldSelect",
                                    "FlowL3Ipv6HashFieldSelect", "FlowL3MplsHashFieldSelect", "Reserved", "FlowNshHashFieldSelect"};
    DbgFibLkpEngineFlowHashInfo_m flow_hash_info;
    DbgIpeFlowProcessInfo_m flow_pro_info;
    DbgIpeFlowProcessInfo_m flow_pro_info2;
    DbgFibLkpEngineXLookupInfo_m xlookup_info;
    DsXLookup0HashKey_m  dsxlookup;
    DsXLookup1HashKey_m  dsxlookup1;
    DsFlow_m  dsflow;
    sal_memset(&flow_hash_info, 0, sizeof(flow_hash_info));
    cmd = DRV_IOR(DbgFibLkpEngineFlowHashInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &flow_hash_info));
    sal_memset(&flow_pro_info, 0, sizeof(flow_pro_info));
    cmd = DRV_IOR(DbgIpeFlowProcessInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &flow_pro_info));
    sal_memset(&flow_pro_info2, 0, sizeof(flow_pro_info2));
    cmd = DRV_IOR(DbgIpeFlowProcessInfo2_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &flow_pro_info2));
    sal_memset(&xlookup_info, 0, sizeof(xlookup_info));
    cmd = DRV_IOR(DbgFibLkpEngineXLookupInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &xlookup_info));

    sal_memset(&dsxlookup, 0, sizeof(dsxlookup));
    sal_memset(&dsxlookup1, 0, sizeof(dsxlookup1));
    sal_memset(&dsflow, 0, sizeof(dsflow));

    if (!GetDbgIpeFlowProcessInfo(V, valid_f, &flow_pro_info))
    {
        return CTC_E_NONE;
    }

    /*xlookup*/
    if (GetDbgFibLkpEngineXLookupInfo(V, valid_f, &xlookup_info))
    {
        DIAG_INFO_NONE(pos, "xlookup")
        GetDbgFibLkpEngineXLookupInfo(A, dbgXLookup0Key_f, &xlookup_info, data_buf0);
        GetDbgFibLkpEngineXLookupInfo(A, dbgXLookup1Key_f, &xlookup_info, data_buf1);
        if (GetDsXLookup0HashKey(V, valid_f, data_buf0) || GetDsXLookup1HashKey(V, valid_f, data_buf1))
        {
            value = GetDbgFibLkpEngineXLookupInfo(V, dbgXLookup0keyIndex_f, &xlookup_info);
            value1 = GetDbgFibLkpEngineXLookupInfo(V, dbgXLookup1keyIndex_f, &xlookup_info);
            if (GetDbgFibLkpEngineXLookupInfo(V, dbgXLookup0hashConflict_f, &xlookup_info))
            {
                DIAG_INFO_CHAR(pos, "hash-0-xlookup-result", DIAG_LOOKUP_CONFLICT)
                DIAG_INFO_UINT32(pos, "key-index", value)
                DIAG_INFO_U32_LIST(pos, "lkup_key", data_buf0, 2)
                DIAG_INFO_XDATA_PROF3(pos,value,GetDsXLookup0HashKey,DsXLookup0HashKey_t,dsxlookup)
            }
            else if (GetDbgFibLkpEngineXLookupInfo(V, dbgXLookup0ResultValid_f, &xlookup_info))
            {
                DIAG_INFO_CHAR(pos, "hash-0-xlookup-result", DIAG_LOOKUP_HIT)
                DIAG_INFO_UINT32(pos, "key-index", value)
                DIAG_INFO_U32_LIST(pos, "lkup_key", data_buf0, 2)
                DIAG_INFO_XDATA_PROF3(pos,value,GetDsXLookup0HashKey,DsXLookup0HashKey_t,dsxlookup)
            }

            if (GetDbgFibLkpEngineXLookupInfo(V, dbgXLookup1hashConflict_f, &xlookup_info))
            {
                DIAG_INFO_CHAR(pos, "hash-1-xlookup-result", DIAG_LOOKUP_CONFLICT)
                DIAG_INFO_UINT32(pos, "key-index", value1)
                DIAG_INFO_U32_LIST(pos, "lkup_key", data_buf1, 2)
                DIAG_INFO_XDATA_PROF(pos,value1,GetDsXLookup1HashKey,DsXLookup1HashKey_t,dsxlookup1)
            }
            else if (GetDbgFibLkpEngineXLookupInfo(V, dbgXLookup1ResultValid_f, &xlookup_info))
            {
                DIAG_INFO_CHAR(pos, "hash-1-xlookup-result", DIAG_LOOKUP_HIT)
                DIAG_INFO_UINT32(pos, "key-index", value1)
                DIAG_INFO_U32_LIST(pos, "lkup_key", data_buf1, 2)
                DIAG_INFO_XDATA_PROF(pos,value1,GetDsXLookup1HashKey,DsXLookup1HashKey_t,dsxlookup1)
            }
        }
        else
        {
            DIAG_INFO_CHAR(pos, "xlookup-result", DIAG_LOOKUP_HIT_NONE)
        }

    }

    /*hash*/
    if (GetDbgFibLkpEngineFlowHashInfo(V, valid_f, &flow_hash_info)
        && GetDbgFibLkpEngineFlowHashInfo(V, flowHashLookupEn_f, &flow_hash_info))
    {
        DIAG_INFO_NONE(pos, "Flow Hash")
        p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
        DIAG_INFO_NONE(pos, "flow-hash-lkup-info")
        DIAG_INFO_U32_HEX(pos, "global-port", SYS_MAP_DRV_GPORT_TO_CTC_GPORT(GetDbgFibLkpEngineFlowHashInfo(V, globalPort_f, &flow_hash_info)))
        DIAG_INFO_UINT32(pos, "local-port", GetDbgFibLkpEngineFlowHashInfo(V, localPhyPort_f, &flow_hash_info))
        DIAG_INFO_UINT32(pos, "logic-port", GetDbgFibLkpEngineFlowHashInfo(V, logicPort_f, &flow_hash_info))
        DIAG_INFO_UINT32(pos, "layer2-type", GetDbgFibLkpEngineFlowHashInfo(V, layer2Type_f, &flow_hash_info))
        DIAG_INFO_UINT32(pos, "layer3-type", GetDbgFibLkpEngineFlowHashInfo(V, layer3Type_f, &flow_hash_info))
        DIAG_INFO_UINT32(pos, "layer4-type", GetDbgFibLkpEngineFlowHashInfo(V, layer4Type_f, &flow_hash_info))
        DIAG_INFO_UINT32(pos, "layer4-user-type", GetDbgFibLkpEngineFlowHashInfo(V, layer4UserType_f, &flow_hash_info))
        DIAG_INFO_CHAR(pos, "pkt-svlan", GetDbgFibLkpEngineFlowHashInfo(V, prSlanIdValid_f, &flow_hash_info)? "Tagged": "Untagged")
        DIAG_INFO_CHAR(pos, "pkt-cvlan", GetDbgFibLkpEngineFlowHashInfo(V, prCvlanIdValid_f, &flow_hash_info)? "Tagged": "Untagged")
        DIAG_INFO_UINT32(pos, "layer2-decode-index", GetDbgFibLkpEngineFlowHashInfo(V, l2DecoderIndex_f, &flow_hash_info))
        DIAG_INFO_UINT32(pos, "layer3-decode-index", GetDbgFibLkpEngineFlowHashInfo(V, l3DecoderIndex_f, &flow_hash_info))
        DIAG_INFO_UINT32(pos, "layer4-decode-index", GetDbgFibLkpEngineFlowHashInfo(V, l4DecoderIndex_f, &flow_hash_info))
        if (GetDbgFibLkpEngineFlowHashInfo(V, svlanIdValid_f, &flow_hash_info))
        {
            DIAG_INFO_UINT32(pos, "svlan-id", GetDbgFibLkpEngineFlowHashInfo(V, svlanId_f, &flow_hash_info))
            DIAG_INFO_UINT32(pos, "stag-cos", GetDbgFibLkpEngineFlowHashInfo(V, stagCos_f, &flow_hash_info))
            DIAG_INFO_UINT32(pos, "stag-cfi", GetDbgFibLkpEngineFlowHashInfo(V, stagCfi_f, &flow_hash_info))
        }
        if (GetDbgFibLkpEngineFlowHashInfo(V, cvlanIdValid_f, &flow_hash_info))
        {
            DIAG_INFO_UINT32(pos, "cvlan-id", GetDbgFibLkpEngineFlowHashInfo(V, cvlanId_f, &flow_hash_info))
            DIAG_INFO_UINT32(pos, "ctag-cos", GetDbgFibLkpEngineFlowHashInfo(V, ctagCos_f, &flow_hash_info))
            DIAG_INFO_UINT32(pos, "ctag-cfi", GetDbgFibLkpEngineFlowHashInfo(V, ctagCfi_f, &flow_hash_info))
        }
        DIAG_INFO_UINT32(pos, "label-num", GetDbgFibLkpEngineFlowHashInfo(V, labelNumOrIpInfo_f, &flow_hash_info))
        value = GetDbgFibLkpEngineFlowHashInfo(V, ipPktLenRangeId_f, &flow_hash_info);
        value = (value << 8) + GetDbgFibLkpEngineFlowHashInfo(V, l4PortRangeBitmap_f, &flow_hash_info);
        DIAG_INFO_UINT32(pos, "range-bmp", value)
        if (GetDbgFibLkpEngineFlowHashInfo(V, ipRoutedPacket_f, &flow_hash_info))
        {
            DIAG_INFO_CHAR(pos, "ip-route-pkt", "Yes")
        }
        if (GetDbgFibLkpEngineFlowHashInfo(V, isNvgre_f, &flow_hash_info))
        {
            DIAG_INFO_CHAR(pos, "nvgre-pkt", "Yes")
        }
        DIAG_INFO_CHAR(pos, "flow-hash-match", GetDbgFibLkpEngineFlowHashInfo(V, flowHashUsePiVlan_f, &flow_hash_info)? "PI Vlan": "Pkt Vlan")
        switch(GetDbgFibLkpEngineFlowHashInfo(V, metadataType_f, &flow_hash_info))
        {
            case DIAG_ACL_METADATA_TYPE_METADATA:
            {
                DIAG_INFO_UINT32(pos, "metadata", GetDbgFibLkpEngineFlowHashInfo(V, metadata_f, &flow_hash_info))
                break;
            }
            case DIAG_ACL_METADATA_TYPE_FID:
            {
                DIAG_INFO_UINT32(pos, "fid", GetDbgFibLkpEngineFlowHashInfo(V, metadata_f, &flow_hash_info))
                break;
            }
            case DIAG_ACL_METADATA_TYPE_VRFID:
            {
                DIAG_INFO_UINT32(pos, "vrfid", GetDbgFibLkpEngineFlowHashInfo(V, metadata_f, &flow_hash_info))
                break;
            }
            case DIAG_ACL_METADATA_TYPE_INVALID:
            default:
                break;
        }
        DIAG_INFO_UINT32(pos, "vrfid", GetDbgFibLkpEngineFlowHashInfo(V, vrfId_f, &flow_hash_info))
        value = GetDbgFibLkpEngineFlowHashInfo(V, hashKeyType_f, &flow_hash_info);
        if (GetDbgFibLkpEngineFlowHashInfo(V, hashConflict_f, &flow_hash_info))
        {
            DIAG_INFO_CHAR(pos, "flow-hash-lkup-result", DIAG_LOOKUP_CONFLICT)
            DIAG_INFO_CHAR(pos, "key-name", str_hash_key_name[value])
            DIAG_INFO_UINT32(pos, "key-index", GetDbgFibLkpEngineFlowHashInfo(V, keyIndex_f, &flow_hash_info))

        }
        else if (GetDbgFibLkpEngineFlowHashInfo(V, lookupResultValid_f, &flow_hash_info))
        {
            DIAG_INFO_CHAR(pos, "flow-hash-lkup-result", DIAG_LOOKUP_HIT)
            DIAG_INFO_CHAR(pos, "key-name", str_hash_key_name[value])
            DIAG_INFO_UINT32(pos, "key-index", GetDbgFibLkpEngineFlowHashInfo(V, keyIndex_f, &flow_hash_info))
            DIAG_INFO_CHAR(pos, "ad-name", "DsFlow")
            DIAG_INFO_UINT32(pos, "ad-index", GetDbgFibLkpEngineFlowHashInfo(V, dsAdIndex_f, &flow_hash_info))
            DIAG_INFO_CHAR(pos, "field-sel-name", str_field_sel_name[value])
            DIAG_INFO_UINT32(pos, "field-sel", GetDbgFibLkpEngineFlowHashInfo(V, flowFieldSel_f, &flow_hash_info))
            DIAG_INFO_XDATA_PROF(pos,GetDbgFibLkpEngineFlowHashInfo(V, dsAdIndex_f, &flow_hash_info),GetDsFlow,DsFlow_t,dsflow)
        }
        else
        {
            DIAG_INFO_CHAR(pos, "flow-hash-lkup-result", DIAG_LOOKUP_HIT_NONE)
        }
    }

    DIAG_INFO_XDATA(pos, GetDbgIpeFlowProcessInfo, flow_pro_info)


    if (GetDbgIpeFlowProcessInfo2(V, valid_f, &flow_pro_info2))
    {
        _sys_at_diag_pkt_tracce_drop_map(lchip, p_rslt,
                                         GetDbgIpeFlowProcessInfo2(V, discard_f, &flow_pro_info2),
                                         GetDbgIpeFlowProcessInfo2(V, discardType_f, &flow_pro_info2));
        /* Exception Process */
        _sys_at_diag_pkt_tracce_exception_map(lchip, p_rslt,
                                              GetDbgIpeFlowProcessInfo2(V, exceptionEn_f, &flow_pro_info2),
                                              GetDbgIpeFlowProcessInfo2(V, exceptionIndex_f, &flow_pro_info2),
                                              GetDbgIpeFlowProcessInfo2(V, exceptionSubIndex_f, &flow_pro_info2));
    }
    else
    {
        /* Drop Process */
        _sys_at_diag_pkt_tracce_drop_map(lchip, p_rslt,
                                         GetDbgIpeFlowProcessInfo(V, discard_f, &flow_pro_info),
                                         GetDbgIpeFlowProcessInfo(V, discardType_f, &flow_pro_info));
        /* Exception Process */
        _sys_at_diag_pkt_tracce_exception_map(lchip, p_rslt,
                                              GetDbgIpeFlowProcessInfo(V, exceptionEn_f, &flow_pro_info),
                                              GetDbgIpeFlowProcessInfo(V, exceptionIndex_f, &flow_pro_info),
                                              GetDbgIpeFlowProcessInfo(V, exceptionSubIndex_f, &flow_pro_info));
    }
    return CTC_E_NONE;
}


STATIC int32
_sys_at_diag_pkt_trace_get_ipe_bridge_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 value = 0;
    uint32 value1 = 0;
    uint32 fid = 0;
    uint32 cmd = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    drv_acc_in_t  in;
    drv_acc_out_t out;
    hw_mac_addr_t hw_mac = {0};
    ipv6_addr_t   hw_ipv6 = {0};
    DbgFibLkpEngineMacDaHashInfo_m mac_da_info;
    DbgIpeMacBridgingInfo_m mac_bridge_info;
    DbgFibLkpEngineFibHashInfo_m fib_info;
    DbgFibLkpEngineFibHost0KeyInfo_m fib_key_info;
    DsMac_m dsmac;
    DsMacDefault_m dsmacdefault;

    sal_memset(&in, 0, sizeof(drv_acc_in_t));
    sal_memset(&out, 0, sizeof(drv_acc_out_t));

    sal_memset(&dsmacdefault, 0, sizeof(dsmacdefault));
    sal_memset(&dsmac, 0, sizeof(dsmac));

    sal_memset(&mac_da_info, 0, sizeof(mac_da_info));
    cmd = DRV_IOR(DbgFibLkpEngineMacDaHashInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &mac_da_info));
    sal_memset(&mac_bridge_info, 0, sizeof(mac_bridge_info));
    cmd = DRV_IOR(DbgIpeMacBridgingInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &mac_bridge_info));
    cmd = DRV_IOR(DbgFibLkpEngineFibHashInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &fib_info));
    cmd = DRV_IOR(DbgFibLkpEngineFibHost0KeyInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &fib_key_info));

    /*bridge process*/
    if (GetDbgIpeMacBridgingInfo(V, valid_f, &mac_bridge_info))
    {
        if (GetDbgFibLkpEngineMacDaHashInfo(V, gMacDaLkp_macDaLookupEn_f, &mac_da_info)
            && GetDbgIpeMacBridgingInfo(V, bridgePacket_f, &mac_bridge_info))
        {
            DIAG_INFO_NONE(pos, "Layer2 Bridging")
            p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
            if (GetDbgFibLkpEngineFibHashInfo(V, valid_f, &fib_info) && GetDbgFibLkpEngineFibHashInfo(V, macDaLookupEn_f, &fib_info))
            {
                DIAG_INFO_CHAR(pos, "macda-lookup", DIAG_ENABLE)
                switch(GetDbgFibLkpEngineFibHost0KeyInfo(V, dbgL2DaHashKeyType_f, &fib_key_info))
                {
                case 4: /*FIBHOST0HASHTYPE_MAC*/
                    GetDbgFibLkpEngineFibHashInfo(A, macDa_f, &fib_info, hw_mac);
                    DIAG_INFO_CHAR(pos, "key-type", "MAC")
                    DIAG_INFO_MAC(pos, "mac-da", hw_mac)
                    DIAG_INFO_UINT32(pos, "vsi-id", GetDbgFibLkpEngineFibHashInfo(V, vsiId_f, &fib_info))
                    break;
                case 5: /*FIBHOST0HASHTYPE_MACIPV6MCAST*/
                    GetDbgFibLkpEngineFibHashInfo(A, l3Dest_f, &fib_info, hw_ipv6);
                    DIAG_INFO_CHAR(pos, "key-type", "MACIPV6MCAST")
                    DIAG_INFO_IP6(pos, "ipv6-da", hw_ipv6)
                    DIAG_INFO_UINT32(pos, "vsi-id", GetDbgFibLkpEngineFibHashInfo(V, vsiId_f, &fib_info))
                    break;
                case 7: /*FIBHOST0HASHTYPE_MACIPV4MCAST*/
                    GetDbgFibLkpEngineFibHashInfo(A, l3Dest_f, &fib_info, hw_ipv6);
                    DIAG_INFO_CHAR(pos, "key-type", "MACIPV4MCAST")
                    DIAG_INFO_CHAR(pos, "ipv4-type", "L2MC")
                    DIAG_INFO_IP4(pos, "ipv4-da", hw_ipv6[0])
                    DIAG_INFO_UINT32(pos, "vrf-id", GetDbgFibLkpEngineFibHashInfo(V, vsiId_f, &fib_info))
                    break;
                default:
                    break;
                }
            }
            if (GetDbgIpeMacBridgingInfo(V, macDaResultValid_f, &mac_bridge_info))
            {
                fid = GetDbgFibLkpEngineMacDaHashInfo(V, gMacDaLkp_vsiId_f, &mac_da_info);
                if (GetDbgFibLkpEngineMacDaHashInfo(V, blackHoleMacDaResultValid_f, &mac_da_info))
                {
                    value = GetDbgFibLkpEngineMacDaHashInfo(V, blackHoleHitMacDaKeyIndex_f, &mac_da_info);
                    cmd = DRV_IOR(DsFibMacBlackHoleHashKey_t, DsFibMacBlackHoleHashKey_dsAdIndex_f);
                    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, value, DRV_CMD_PP_EN(cmd), &value1));

                    DIAG_INFO_CHAR(pos, "macda-lookup-result", "HIT-BLACKHOLE-ENTRY")
                    DIAG_INFO_CHAR(pos, "key-name", "DsFibMacBlackHoleHashKey")
                    DIAG_INFO_UINT32(pos, "key-index", value)
                    DIAG_INFO_CHAR(pos, "ad-name", "DsMac")
                    DIAG_INFO_UINT32(pos, "ad-index", value1)
                }
                else if (GetDbgIpeMacBridgingInfo(V, macDaDefaultEntryValid_f, &mac_bridge_info))
                {
                    cmd = DRV_IOR(FibEngineLookupResultCtl_t, FibEngineLookupResultCtl_gMacDaLookupResultCtl_defaultEntryBase_f);
                    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &value));
                    DIAG_INFO_CHAR(pos, "macda-lookup-result", DIAG_LOOKUP_DEFAULT)
                    DIAG_INFO_UINT32(pos, "bridge-fid", fid)
                    DIAG_INFO_CHAR(pos, "ad-name", "DsMac")
                    DIAG_INFO_UINT32(pos, "ad-index", (fid + (value << 8)))
                    DIAG_INFO_XDATA_PROF3(pos,(fid + (value << 8)),GetDsMacDefault,DsMacDefault_t,dsmacdefault)
                }
                else if (GetDbgFibLkpEngineMacDaHashInfo(V, valid_f, &mac_da_info)
                    && GetDbgFibLkpEngineMacDaHashInfo(V, gMacDaLkpResult_macDaResultValid_f, &mac_da_info))
                {
                    value = GetDbgFibLkpEngineFibHost0KeyInfo(V, dbgL2DaKeyIndex_f, &fib_key_info);
                    value1 = GetDbgFibLkpEngineFibHost0KeyInfo(V, dbgL2DaAdIndex_f, &fib_key_info);

                    DIAG_INFO_CHAR(pos, "macda-lookup-result", DIAG_LOOKUP_HIT)
                    DIAG_INFO_CHAR(pos, "key-name", "DsFibHost0MacHashKey")
                    DIAG_INFO_UINT32(pos, "key-index", value)
                    DIAG_INFO_CHAR(pos, "ad-name", "DsMac")
                    DIAG_INFO_UINT32(pos, "ad-index", value1)
                    DIAG_INFO_XDATA_PROF3(pos,value1,GetDsMac,DsMac_t,dsmac)
                }
                else
                {
                    DIAG_INFO_CHAR(pos, "macda-lookup-result", DIAG_LOOKUP_HIT_NONE)
                }
            }
            if (GetDbgIpeMacBridgingInfo(V, bridgeEscape_f, &mac_bridge_info))
            {
                DIAG_INFO_CHAR(pos, "bridge-escape", "ENABLE")
            }
            if (GetDbgIpeMacBridgingInfo(V, stormCtlEn_f, &mac_bridge_info))
            {
                DIAG_INFO_CHAR(pos, "bridge-stromctl", "ENABLE")
            }
            DIAG_INFO_XDATA(pos , GetDbgIpeMacBridgingInfo, mac_bridge_info)
        }
        /* Drop Process */
        _sys_at_diag_pkt_tracce_drop_map(lchip,p_rslt,
                                            GetDbgIpeMacBridgingInfo(V, discard_f, &mac_bridge_info),
                                            GetDbgIpeMacBridgingInfo(V, discardType_f, &mac_bridge_info));
        /* Exception Process */
        _sys_at_diag_pkt_tracce_exception_map(lchip,p_rslt,
                                                GetDbgIpeMacBridgingInfo(V, exceptionEn_f, &mac_bridge_info),
                                                GetDbgIpeMacBridgingInfo(V, exceptionIndex_f, &mac_bridge_info),
                                                GetDbgIpeMacBridgingInfo(V, exceptionSubIndex_f, &mac_bridge_info));
    }

    return CTC_E_NONE;
}

STATIC int32
_sys_at_diag_pkt_trace_get_ipe_learn_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 value = 0;
    uint32 ad_index = 0;
    uint32 fid = 0;
    uint32 cmd = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    hw_mac_addr_t hw_mac = {0};
    DbgFibLkpEngineMacSaHashInfo_m mac_sa_info;
    DbgIpeMacLearningInfo_m mac_learn_info;
    DbgFibLkpEngineFibHashInfo_m fib_info;
    DbgIpeFwdProcessInfo_m fwd_proc_info;
    drv_acc_in_t  in;
    drv_acc_out_t out;

    sal_memset(&in, 0, sizeof(drv_acc_in_t));
    sal_memset(&out, 0, sizeof(drv_acc_out_t));
    sal_memset(&mac_learn_info, 0, sizeof(mac_learn_info));
    cmd = DRV_IOR(DbgIpeMacLearningInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &mac_learn_info));
    sal_memset(&mac_sa_info, 0, sizeof(mac_sa_info));
    cmd = DRV_IOR(DbgFibLkpEngineMacSaHashInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &mac_sa_info));
    cmd = DRV_IOR(DbgFibLkpEngineFibHashInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &fib_info));
    cmd = DRV_IOR(DbgIpeFwdProcessInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &fwd_proc_info));

    if (!GetDbgIpeMacLearningInfo(V, valid_f, &mac_learn_info))
    {
        return CTC_E_NONE;
    }

    if (GetDbgFibLkpEngineMacSaHashInfo(V, gMacSaLkp_macSaLookupEn_f, &mac_sa_info))
    {
        DIAG_INFO_NONE(pos, "Learning")
        p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
        fid = GetDbgIpeMacLearningInfo(V, learningFid_f, &mac_learn_info);

        if (GetDbgFibLkpEngineFibHashInfo(V, valid_f, &fib_info) && GetDbgFibLkpEngineFibHashInfo(V, macSaLookupEn_f, &fib_info))
        {
            DIAG_INFO_CHAR(pos, "macsa-lookup", DIAG_ENABLE)
            GetDbgFibLkpEngineFibHashInfo(A, macSa_f, &fib_info, hw_mac);
            DIAG_INFO_MAC(pos, "mac-sa", hw_mac)
            DIAG_INFO_UINT32(pos, "vsi-id", GetDbgFibLkpEngineFibHashInfo(V, vsiId_f, &fib_info))
        }
        if (GetDbgFibLkpEngineMacSaHashInfo(V, gMacSaLkpResult_cacheLookupEn_f, &mac_sa_info))
        {
            DIAG_INFO_CHAR(pos, "cache-lookup", DIAG_ENABLE)
            DIAG_INFO_CHAR(pos, "cache-hit", GetDbgFibLkpEngineMacSaHashInfo(V, gMacSaLkpResult_cacheHit_f, &mac_sa_info) ? DIAG_LOOKUP_HIT : DIAG_LOOKUP_HIT_NONE)
            DIAG_INFO_CHAR(pos, "cache-free-valid", GetDbgFibLkpEngineMacSaHashInfo(V, gMacSaLkpResult_cacheFreeValid_f, &mac_sa_info)? DIAG_YES : DIAG_NO)
            DIAG_INFO_UINT32(pos, "cache-entry-index", GetDbgFibLkpEngineMacSaHashInfo(V, gMacSaLkpResult_cacheEntryIndex_f, &mac_sa_info))
        }
        else
        {
            DIAG_INFO_CHAR(pos, "cache-lookup", DIAG_DISABLE)
        }

        if (GetDbgIpeMacLearningInfo(V, macSaHashConflict_f, &mac_learn_info))
        {
            DIAG_INFO_CHAR(pos, "macsa-lookup-result", DIAG_LOOKUP_CONFLICT)
            value = GetDbgFibLkpEngineMacSaHashInfo(V, gMacSaLkpResult_macSaHashKeyHitIndex_f, &mac_sa_info);
            in.type = DRV_ACC_TYPE_LOOKUP;
            in.tbl_id = DsFibHost0MacHashKey_t;
            in.index =  value;
            in.op_type = DRV_ACC_OP_BY_INDEX;
            drv_acc_get_hash_module(lchip, in.tbl_id, &in.module);
            CTC_ERROR_RETURN(drv_acc_api(lchip, &in, &out));
            drv_get_field(lchip, DsFibHost0MacHashKey_t, DsFibHost0MacHashKey_dsAdIndex_f, out.data, &ad_index);
            DIAG_INFO_CHAR(pos, "key-name", "DsFibHost0HashMacCam")
            DIAG_INFO_UINT32(pos, "key-index", value)
            DIAG_INFO_CHAR(pos, "ad-name", "DsMac")
            DIAG_INFO_UINT32(pos, "ad-index", ad_index)
        }
        else if (GetDbgIpeMacLearningInfo(V, macSaResultValid_f, &mac_learn_info)&&(!GetDbgIpeMacLearningInfo(V, macSaDefaultEntryValid_f, &mac_learn_info)))
        {
            DIAG_INFO_CHAR(pos, "macsa-lookup-result", DIAG_LOOKUP_HIT)
            value = GetDbgFibLkpEngineMacSaHashInfo(V, gMacSaLkpResult_macSaHashKeyHitIndex_f, &mac_sa_info);
            in.type = DRV_ACC_TYPE_LOOKUP;
            in.tbl_id = DsFibHost0MacHashKey_t;
            in.index =  value;
            in.op_type = DRV_ACC_OP_BY_INDEX;
            drv_acc_get_hash_module(lchip, in.tbl_id, &in.module);
            CTC_ERROR_RETURN(drv_acc_api(lchip, &in, &out));
            drv_get_field(lchip, DsFibHost0MacHashKey_t, DsFibHost0MacHashKey_dsAdIndex_f, out.data, &ad_index);
            DIAG_INFO_CHAR(pos, "key-name", "DsFibHost0MacHashKey")
            DIAG_INFO_UINT32(pos, "key-index", value)
            DIAG_INFO_CHAR(pos, "ad-name", "DsMac")
            DIAG_INFO_UINT32(pos, "ad-index", ad_index)
        }
        else if (GetDbgIpeMacLearningInfo(V, macSaDefaultEntryValid_f, &mac_learn_info))
        {
            DIAG_INFO_CHAR(pos, "macsa-lookup-result", DIAG_LOOKUP_DEFAULT)
        }
        else
        {
            DIAG_INFO_CHAR(pos, "macsa-lookup-result", DIAG_LOOKUP_HIT_NONE)
        }

        if (GetDbgIpeMacLearningInfo(V, learningEn_f, &mac_learn_info))
        {
            DIAG_INFO_CHAR(pos, "learning-mode", (GetDbgIpeMacLearningInfo(V, learningType_f, &mac_learn_info) ? "HW" : "SW"))
            DIAG_INFO_UINT32(pos, "learning-fid", fid)
            value = GetDbgIpeMacLearningInfo(V, learningSrcPort_f, &mac_learn_info);
            if (!GetDbgIpeMacLearningInfo(V, learningUseGlobalSrcPort_f, &mac_learn_info))
            {
                DIAG_INFO_UINT32(pos, "learning-logic-port", value)
            }
            else
            {
                DIAG_INFO_U32_HEX(pos, "learning-global-port", SYS_MAP_DRV_GPORT_TO_CTC_GPORT(value))
            }
            DIAG_INFO_UINT32(pos, "aging-ptr", GetDbgIpeMacLearningInfo(V, agingIndex_f, &mac_learn_info))
        }
        DIAG_INFO_CHAR(pos, "do-learning",(GetDbgIpeFwdProcessInfo(V, valid_f, &fwd_proc_info)&&GetDbgIpeFwdProcessInfo(V, doLearningOperation_f, &fwd_proc_info))?DIAG_YES:DIAG_NO)
    }

    /* Drop Process */
    _sys_at_diag_pkt_tracce_drop_map(lchip,p_rslt,
                                          GetDbgIpeMacLearningInfo(V, discard_f, &mac_learn_info),
                                          GetDbgIpeMacLearningInfo(V, discardType_f, &mac_learn_info));
    /* Exception Process */
    _sys_at_diag_pkt_tracce_exception_map(lchip,p_rslt,
                                               GetDbgIpeMacLearningInfo(V, exceptionEn_f, &mac_learn_info),
                                               GetDbgIpeMacLearningInfo(V, exceptionIndex_f, &mac_learn_info),
                                               GetDbgIpeMacLearningInfo(V, exceptionSubIndex_f, &mac_learn_info));
    return CTC_E_NONE;
}

STATIC int32
_sys_at_diag_pkt_trace_get_route_tbl_id(uint8 lchip, uint32 pri_valid, uint32 tcam_group_index, uint32 key_type, uint32* key_id, uint32* ad_id)
{
    uint32 cmd = 0;
    LpmTcamCtl_m lpm_tcam_ctl;

    sal_memset( &lpm_tcam_ctl, 0, sizeof(LpmTcamCtl_m));
    cmd = DRV_IOR(LpmTcamCtl_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &lpm_tcam_ctl));

    if (SYS_AT_DIAG_L3DA_TYPE_IPV4UC == key_type)
    {
        *key_id = pri_valid ? DsLpmTcamIpv4HalfKey_t : DsLpmTcamIpv4DaPubHalfKey_t;
        *ad_id = pri_valid ? DsLpmTcamIpv4HalfKeyAd_t : DsLpmTcamIpv4DaPubHalfKeyAd_t;
    }
    else if (SYS_AT_DIAG_L3DA_TYPE_IPV6UC == key_type && !GetLpmTcamCtl(V, tcamGroupConfig_0_ipv6Lookup64Prefix_f + tcam_group_index, &lpm_tcam_ctl))
    {
        *key_id = pri_valid ? DsLpmTcamIpv6DoubleKey0_t : DsLpmTcamIpv6DaPubDoubleKey0_t;
        *ad_id = pri_valid ? DsLpmTcamIpv6DoubleKey0Ad_t : DsLpmTcamIpv6DaPubDoubleKey0Ad_t;
    }
    else if (SYS_AT_DIAG_L3DA_TYPE_IPV6UC == key_type && GetLpmTcamCtl(V, tcamGroupConfig_0_ipv6Lookup64Prefix_f + tcam_group_index, &lpm_tcam_ctl))
    {
        *key_id = pri_valid ? DsLpmTcamIpv6SingleKey_t : DsLpmTcamIpv6DaPubSingleKey_t;
        *ad_id = pri_valid ? DsLpmTcamIpv6SingleKeyAd_t : DsLpmTcamIpv6DaPubSingleKeyAd_t;
    }

    return CTC_E_NONE;
}

STATIC int32
_sys_at_diag_pkt_trace_map_ipuc_key_index(uint8 lchip, uint32 tbl_id, uint32 key_index, uint32* mapped_key_idx, uint32* mapped_ad_idx)
{
#if (SDK_WORK_PLATFORM == 0)
    uint8 block_num = 0;
    uint8 blk_id = 0;
    uint16 blk_offset = 0;
    uint32 local_index = 0;
    uint32 blk_size = 0;

    block_num = (key_index >> DIAG_LPM_TCAM_LOCAL_BIT_LEN)&0x3 ;
    local_index = key_index & ((1<<DIAG_LPM_TCAM_LOCAL_BIT_LEN )-1);

    blk_size = ((block_num <= 1) ? (DIAG_LPM_TCAM_MAX_ENTRY_NUM/2) : (DIAG_LPM_TCAM_MAX_ENTRY_NUM));

    blk_id = local_index /blk_size + block_num * 2;
    blk_offset = local_index - local_index / blk_size * blk_size;

    *mapped_key_idx = (DRV_TCAM_START_INDEX(lchip, DsLpmTcamIpv4HalfKey_t, blk_id) +  blk_offset)/(DRV_TCAM_KEY_SIZE(lchip, tbl_id) / DRV_LPM_KEY_BYTES_PER_ENTRY) ;
    *mapped_ad_idx = DRV_TCAM_START_INDEX(lchip, DsLpmTcamIpv4HalfKeyAd_t, blk_id) +  blk_offset;
#endif

#if (SDK_WORK_PLATFORM == 1)
    *mapped_key_idx = key_index/(DRV_TCAM_KEY_SIZE(lchip, tbl_id) / DRV_LPM_KEY_BYTES_PER_ENTRY);
    *mapped_ad_idx = key_index;
#endif
    return CTC_E_NONE;

}

STATIC int32
_sys_at_diag_pkt_trace_get_ipe_route_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    uint32 cmd = 0;
    uint32 value = 0;
    uint8 index = 0;
    uint8  step = 0;
    uint32 key_index = 0;
    uint32 grp0_valid[6] = {0};
    uint32 grp0_index[6] = {0};
    char* key_name = "Unknown..";
    char* ad_name = "Unknown..";
    DbgFibLkpEngineL3DaHashInfo_m l3_da_info;
    DbgFibLkpEngineL3SaHashInfo_m l3_sa_info;
    DbgFibLkpEngineHostUrpfHashInfo_m urpf_info;
    DbgLpmTcamEngineResult0Info_m lpm_res0;
    DbgIpeIpRoutingInfo_m routing_info;
    DbgFibLkpEngineFibHashInfo_m fib_info;
    FibEngineLookupCtl_m fib_engine_lookup_ctl;
    DsIpDa_m dsipda;
    char *sys_diag_fib_l3da_key[] = {
        "IPV4UCAST",    "IPV6UCAST",    "IPV4MCAST",    "IPV6MCAST",
        "FCOE",         "TRILLUCAST",   "TRILLMCAST",   "RESERVED"};

    sal_memset(&l3_da_info, 0, sizeof(l3_da_info));
    cmd = DRV_IOR(DbgFibLkpEngineL3DaHashInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &l3_da_info));
    sal_memset(&l3_sa_info, 0, sizeof(l3_sa_info));
    cmd = DRV_IOR(DbgFibLkpEngineL3SaHashInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &l3_sa_info));
    sal_memset(&urpf_info, 0, sizeof(urpf_info));
    cmd = DRV_IOR(DbgFibLkpEngineHostUrpfHashInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &urpf_info));
    sal_memset(&routing_info, 0, sizeof(routing_info));
    cmd = DRV_IOR(DbgIpeIpRoutingInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &routing_info));
    sal_memset(&lpm_res0, 0, sizeof(lpm_res0));
    cmd = DRV_IOR(DbgLpmTcamEngineResult0Info_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &lpm_res0));
    cmd = DRV_IOR(DbgFibLkpEngineFibHashInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &fib_info));
    step = DbgLpmTcamEngineResult0Info_gTcamGroup_1_lookupResultValid_f - DbgLpmTcamEngineResult0Info_gTcamGroup_0_lookupResultValid_f;
    cmd = DRV_IOR(FibEngineLookupCtl_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &fib_engine_lookup_ctl));

    sal_memset(&dsipda, 0, sizeof(dsipda));

    for (index = 0; index < 6; index++)
    {
        DRV_IOR_FIELD(lchip, DbgLpmTcamEngineResult0Info_t, DbgLpmTcamEngineResult0Info_gTcamGroup_0_lookupResultValid_f+index*step,
            &grp0_valid[index], &lpm_res0);

        DRV_IOR_FIELD(lchip, DbgLpmTcamEngineResult0Info_t, DbgLpmTcamEngineResult0Info_gTcamGroup_0_tcamHitIndex_f+index*step,
            &grp0_index[index], &lpm_res0);
    }

    if (!GetDbgIpeIpRoutingInfo(V, valid_f, &routing_info))
    {
        return CTC_E_NONE;
    }

    if (!(GetDbgFibLkpEngineL3DaHashInfo(V, l3DaLookupEn_f, &l3_da_info)
        || GetDbgFibLkpEngineL3SaHashInfo(V, l3SaLookupEn_f, &l3_sa_info)))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
    DIAG_INFO_NONE(pos, "Layer3 Routing")
    if (GetDbgFibLkpEngineL3DaHashInfo(V, l3DaLookupEn_f, &l3_da_info))
    {
        if (GetDbgFibLkpEngineFibHashInfo(V, valid_f, &fib_info) && GetDbgFibLkpEngineFibHashInfo(V, l3DaLookupEn_f, &fib_info))
        {
            DIAG_INFO_CHAR(pos, "ipda-lookup", DIAG_ENABLE)
            DIAG_INFO_CHAR(pos, "key-type", sys_diag_fib_l3da_key[GetDbgFibLkpEngineFibHashInfo(V, l3DaKeyType_f, &fib_info)])
        }
        if (GetDbgIpeIpRoutingInfo(V, ipHeaderError_f, &routing_info))
        {
            DIAG_INFO_CHAR(pos, "ipda-lookup-result", "IP-HEADER-ERROR")
        }
        else if (GetDbgIpeIpRoutingInfo(V, ipDaResultValid_f, &routing_info))
        {
            if (GetDbgFibLkpEngineL3DaHashInfo(V, hostHashFirstL3DaResultValid_f, &l3_da_info)
                || GetDbgFibLkpEngineL3DaHashInfo(V, hostHashSecondDaResultValid_f, &l3_da_info))
            {
                char* key_name = "Unknown..";
                DIAG_INFO_CHAR(pos, "ipda-lookup-result", "HIT-HASH")
                DIAG_INFO_UINT32(pos, "vrf-id", GetDbgFibLkpEngineL3DaHashInfo(V, vrfId_f, &l3_da_info))

                value = GetDbgFibLkpEngineL3DaHashInfo(V, l3DaKeyType_f, &l3_da_info);
                if ((SYS_AT_DIAG_L3DA_TYPE_IPV4UC == value) ||
                    (SYS_AT_DIAG_L3DA_TYPE_IPV4MC == value))/* FIBDAKEYTYPE_IPV4UCAST or FIBDAKEYTYPE_IPV4MCAST */
                {
                    key_name = (GetDbgFibLkpEngineL3DaHashInfo(V, natDaValid_f, &l3_da_info)
                                && GetDbgFibLkpEngineL3DaHashInfo(V, hostHashSecondDaResultValid_f, &l3_da_info)) ? "DsFibHost1Ipv4NatDaPortHashKey" : "DsFibHost0Ipv4HashKey";
                    ad_name = "DsIpDa";
                }
                else if (SYS_AT_DIAG_L3DA_TYPE_IPV6UC == value)/* FIBDAKEYTYPE_IPV6UCAST */
                {
                    key_name = (GetDbgFibLkpEngineL3DaHashInfo(V, natDaValid_f, &l3_da_info)
                                && GetDbgFibLkpEngineL3DaHashInfo(V, hostHashSecondDaResultValid_f, &l3_da_info)) ? "DsFibHost1Ipv6NatDaPortHashKey" : "DsFibHost0Ipv6UcastHashKey";
                    ad_name = "DsIpDa";
                }
                else if (SYS_AT_DIAG_L3DA_TYPE_IPV6MC == value)/* FIBDAKEYTYPE_IPV6MCAST */
                {
                    key_name = "DsFibHost0MacIpv6McastHashKey";
                    ad_name = "DsIpDa";
                }
                else if (SYS_AT_DIAG_L3DA_TYPE_TRILLUC == value)
                {
                    key_name = "DsFibHost0TrillHashKey";
                    ad_name = "DsTrillDa";
                }
                else if (SYS_AT_DIAG_L3DA_TYPE_TRILLMC == value)
                {
                    key_name = "DsFibHost1TrillMcastVlanHashKey";
                    ad_name = "DsTrillDa";
                }
                else if (SYS_AT_DIAG_L3DA_TYPE_FCOE== value)
                {
                    key_name = "DsFibHost0FcoeHashKey";
                    ad_name = "DsFcoeDa";
                }

                DIAG_INFO_CHAR(pos, "key-name", key_name)
                value = GetDbgFibLkpEngineL3DaHashInfo(V, hostHashFirstL3DaResultValid_f, &l3_da_info)
                        ? GetDbgFibLkpEngineL3DaHashInfo(V, hostHashFirstL3DaKeyIndex_f, &l3_da_info)
                        : GetDbgFibLkpEngineL3DaHashInfo(V, hostHashSecondDaKeyIndex_f, &l3_da_info);
                DIAG_INFO_UINT32(pos, "key-index", value)
                DIAG_INFO_CHAR(pos, "ad-name", ad_name)
            }
            else if (GetDbgFibLkpEngineL3DaHashInfo(V, l3DaTcamLookup1PrivateResultValid_f, &l3_da_info)
                || GetDbgFibLkpEngineL3DaHashInfo(V, l3DaTcamLookup1PublicResultValid_f, &l3_da_info))
            {
                char str[64] = {0};
                uint32 key_table_id = 0;
                uint32 ad_table_id = 0;
                uint32 mapped_key_index = 0;
                uint32 mapped_ad_index = 0;
                DIAG_INFO_CHAR(pos, "ipda-lookup-result", "HIT-LPM-TCAM")

                if (GetDbgFibLkpEngineL3DaHashInfo(V, l3DaTcamLookup1PrivateResultValid_f, &l3_da_info))
                {
                    for (index = 0; index < 6; index++)
                    {
                        if (!grp0_valid[index])
                        {
                            continue;
                        }
                        key_index = grp0_index[index];
                        sal_sprintf(str, "lookup1-private-block-%d", index);
                        DIAG_INFO_CHAR(pos, "tcam-key", str)
                        break;
                    }
                }

                if (GetDbgFibLkpEngineL3DaHashInfo(V, l3DaTcamLookup1PublicResultValid_f, &l3_da_info))
                {
                    for (index = 0; index < 6; index++)
                    {
                        if (!grp0_valid[index])
                        {
                            continue;
                        }
                        key_index = grp0_index[index];
                        sal_sprintf(str, "lookup1-public-block-%d", index);
                        DIAG_INFO_CHAR(pos, "tcam-key", str)
                        break;
                    }
                }

                value = GetDbgFibLkpEngineL3DaHashInfo(V, l3DaKeyType_f, &l3_da_info);
                CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_route_tbl_id(lchip,
                                        GetDbgFibLkpEngineL3DaHashInfo(V, l3DaTcamLookup1PrivateResultValid_f, &l3_da_info),
                                        index, value, &key_table_id, &ad_table_id));

                if (SYS_AT_DIAG_L3DA_TYPE_IPV4UC == value)
                {
                    key_name = DRV_TABLE_NAME(lchip, key_table_id);
                    ad_name = DRV_TABLE_NAME(lchip, ad_table_id);
                    _sys_at_diag_pkt_trace_map_ipuc_key_index(lchip, key_table_id, key_index, &mapped_key_index, &mapped_ad_index);
                }
                else if (SYS_AT_DIAG_L3DA_TYPE_IPV6UC == value)
                {
                    key_name = DRV_TABLE_NAME(lchip, key_table_id);
                    ad_name = DRV_TABLE_NAME(lchip, ad_table_id);
                    _sys_at_diag_pkt_trace_map_ipuc_key_index(lchip, key_table_id, key_index, &mapped_key_index, &mapped_ad_index);
                }
                DIAG_INFO_UINT32(pos, "spec-tcam-index", key_index)
                DIAG_INFO_CHAR(pos, "key-name", key_name)
                DIAG_INFO_UINT32(pos, "key-index", mapped_key_index)
                DIAG_INFO_CHAR(pos, "tcam-ad-name", ad_name)
                DIAG_INFO_UINT32(pos, "tcam-ad-index", mapped_ad_index)
                DIAG_INFO_CHAR(pos, "ad-name", "DsIpDa")

            }
              DIAG_INFO_UINT32(pos, "ad-index", GetDbgFibLkpEngineL3DaHashInfo(V, l3DaAdindexForDebug_f, &l3_da_info))
              value = GetDbgFibLkpEngineL3DaHashInfo(V, l3DaKeyType_f, &l3_da_info);
              if(value == SYS_AT_DIAG_L3DA_TYPE_IPV4UC || value == SYS_AT_DIAG_L3DA_TYPE_IPV6UC)
              {
                  DIAG_INFO_XDATA_PROF3(pos,GetDbgFibLkpEngineL3DaHashInfo(V, l3DaAdindexForDebug_f, &l3_da_info),GetDsIpDa,DsIpDa_t,dsipda)
              }
        }
        else
        {
            DIAG_INFO_CHAR(pos, "ipda-lookup-result", DIAG_LOOKUP_HIT_NONE)
        }
    }

    if (GetDbgFibLkpEngineL3SaHashInfo(V, l3SaLookupEn_f, &l3_sa_info))
    {
        if (GetDbgIpeIpRoutingInfo(V, ipSaResultValid_f, &routing_info))
        {
            char* result = "Unknown..";


            value = GetDbgFibLkpEngineL3SaHashInfo(V, l3SaKeyType_f, &l3_sa_info);
            if (value == SYS_AT_DIAG_L3SA_TYPE_IPV4NATSA)
            {
                if (GetDbgFibLkpEngineL3SaHashInfo(V, hostHashFirstSaNatTcamResultValid_f, &l3_sa_info))
                {
                    result = "HIT-LPM-TCAM-IPv4-NAT";
                    key_name = "DsLpmTcamIpv4NatDoubleKey";
                    key_index = GetDbgFibLkpEngineL3SaHashInfo(V, hostHashFirstSaTcamHitIndex_f, &l3_sa_info);
                    key_index = (key_index - DRV_TABLE_MAX_INDEX(lchip, DsLpmTcamIpv4HalfKey_t)) /
                                (DRV_TCAM_KEY_SIZE(lchip, DsLpmTcamIpv4NatDoubleKey_t) / DRV_TCAM_KEY_SIZE(lchip, DsLpmTcamIpv4HalfKey_t));
                    ad_name = "DsIpSaNat";
                }
                else if (GetDbgFibLkpEngineL3SaHashInfo(V, l3SaResultValid_f, &l3_sa_info))
                {
                    result = "HIT-HASH-IPv4-NAT";
                    key_name = "DsFibHost1Ipv4NatSaPortHashKey";
                    key_index = GetDbgFibLkpEngineL3SaHashInfo(V, hostHashSecondSaKeyIndex_f, &l3_sa_info);
                    ad_name = "DsIpSaNat";
                }
            }
            else if (value == SYS_AT_DIAG_L3SA_TYPE_IPV6NATSA)
            {
                if (GetDbgFibLkpEngineL3SaHashInfo(V, hostHashFirstSaNatTcamResultValid_f, &l3_sa_info))
                {
                    result = "HIT-LPM-TCAM-IPv6-NAT";
                    key_name = "TempDsLpmTcamIpv6NatDoubleKey";
                    key_index = GetDbgFibLkpEngineL3SaHashInfo(V, hostHashFirstSaTcamHitIndex_f, &l3_sa_info);
                    key_index = (key_index - DRV_TABLE_MAX_INDEX(lchip, DsLpmTcamIpv4HalfKey_t)) /
                                (DRV_TCAM_KEY_SIZE(lchip, TempDsLpmTcamIpv6NatDoubleKey_t) / DRV_TCAM_KEY_SIZE(lchip, DsLpmTcamIpv4HalfKey_t));
                    ad_name = "DsIpSaNat";
                }
                else if (GetDbgFibLkpEngineL3SaHashInfo(V, l3SaResultValid_f, &l3_sa_info))
                {
                    result = "HIT-HASH-IPv6-NAT";
                    key_name = "DsFibHost1Ipv6NatSaPortHashKey";
                    key_index = GetDbgFibLkpEngineL3SaHashInfo(V, hostHashSecondSaKeyIndex_f, &l3_sa_info);
                    ad_name = "DsIpSaNat";
                }
            }
            else if (value == SYS_AT_DIAG_L3SA_TYPE_IPV4RPF)
            {
                if (GetDbgFibLkpEngineL3SaHashInfo(V, hostHashFirstSaRpfTcamResultValid_f, &l3_sa_info))
                {
                    result = "HIT-LPM-TCAM-IPv4-RPF";
                    key_name = "DsLpmTcamIpv4HalfKey";
                    key_index = GetDbgFibLkpEngineL3SaHashInfo(V, hostHashFirstSaTcamHitIndex_f, &l3_sa_info);
                    ad_name = "DsIpDa";
                }
                else if (GetDbgFibLkpEngineL3SaHashInfo(V, l3SaResultValid_f, &l3_sa_info))
                {
                    result = "HIT-HASH-IPv4-RPF";
                    key_name = "DsFibHost0Ipv4HashKey";
                    key_index = GetDbgFibLkpEngineHostUrpfHashInfo(V, hostUrpfHashHitIndex_f, &urpf_info);
                    ad_name = "DsIpDa";
                }
            }
            else if (value == SYS_AT_DIAG_L3SA_TYPE_IPV6RPF)
            {
                if (GetDbgFibLkpEngineL3SaHashInfo(V, hostHashFirstSaRpfTcamResultValid_f, &l3_sa_info))
                {
                    result = "HIT-LPM-TCAM-IPv6-RPF";
                    key_name = "DsLpmTcamIpv6DoubleKey0";
                    key_index = GetDbgFibLkpEngineL3SaHashInfo(V, hostHashFirstSaTcamHitIndex_f, &l3_sa_info);
                    ad_name = "DsIpDa";
                }
                else if (GetDbgFibLkpEngineL3SaHashInfo(V, l3SaResultValid_f, &l3_sa_info))
                {
                    result = "HIT-HASH-IPv6-RPF";
                    key_name = "DsFibHost0Ipv6UcastHashKey";
                    key_index = GetDbgFibLkpEngineHostUrpfHashInfo(V, hostUrpfHashHitIndex_f, &urpf_info);
                    ad_name = "DsIpDa";
                }
            }
            else if (value == SYS_AT_DIAG_L3SA_TYPE_FCOERPF)
            {
                result = "HIT-HASH-FCoE-RPF";
                key_name = "DsFibHost1FcoeRpfHashKey";
                key_index = GetDbgFibLkpEngineL3SaHashInfo(V, hostHashSecondSaKeyIndex_f, &l3_sa_info);
                ad_name = "DsIpDa";

            }

            DIAG_INFO_CHAR(pos, "ipsa-lookup-result", result)
            DIAG_INFO_CHAR(pos, "key-name", key_name)
            DIAG_INFO_UINT32(pos, "key-index", key_index)
            DIAG_INFO_CHAR(pos, "ad-name", ad_name)
            DIAG_INFO_UINT32(pos, "ad-index", GetDbgFibLkpEngineL3SaHashInfo(V, l3SaAdindexForDebug_f, &l3_sa_info))

        }
        else
        {
            DIAG_INFO_CHAR(pos, "ipsa-lookup-result", DIAG_LOOKUP_HIT_NONE)
        }
    }

    if (GetDbgIpeIpRoutingInfo(V, routingEscape_f, &routing_info))
    {
        DIAG_INFO_CHAR(pos, "routing-escape", "ENABLE")
    }
    DIAG_INFO_XDATA(pos, GetDbgIpeIpRoutingInfo, routing_info)

    /* Drop Process */
    _sys_at_diag_pkt_tracce_drop_map(lchip,p_rslt,
                                          GetDbgIpeIpRoutingInfo(V, discard_f, &routing_info),
                                          GetDbgIpeIpRoutingInfo(V, discardType_f, &routing_info));
    /* Exception Process */
    _sys_at_diag_pkt_tracce_exception_map(lchip,p_rslt,
                                               GetDbgIpeIpRoutingInfo(V, exceptionEn_f, &routing_info),
                                               GetDbgIpeIpRoutingInfo(V, exceptionIndex_f, &routing_info),
                                               GetDbgIpeIpRoutingInfo(V, exceptionSubIndex_f, &routing_info));
    return CTC_E_NONE;
}

STATIC int32
_sys_at_diag_pkt_trace_get_lag_info(uint8 lchip, DbgLagEngineInfo_m* lag_info, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    IpeToLagEngineInput_m ipe_lag_input;
    LagEngineOutput_m  lag_ouput;

    GetDbgLagEngineInfo(A, lagEngineInput_f, lag_info, &ipe_lag_input);
    GetDbgLagEngineInfo(A, lagEngineOutput_f, lag_info, &lag_ouput);

    if (GetDbgLagEngineInfo(V, sgmacLagEnable_f, lag_info))
    {
        DIAG_INFO_CHAR(pos, "Linkagg Process", "sgmac-linkagg")
        DIAG_INFO_UINT32(pos, "cFlexSgGroupSel", GetIpeToLagEngineInput(V, cFlexFwdSgGroupSel_f, &ipe_lag_input))
        DIAG_INFO_UINT32(pos, "cFlexLagHash", GetIpeToLagEngineInput(V, cFlexLagHash_f, &ipe_lag_input))
        DIAG_INFO_UINT32(pos, "stackingDiscard", GetLagEngineOutput(V, stackingDiscard_f, &lag_ouput))
        DIAG_INFO_UINT32(pos, "dest-sgmac-group", GetLagEngineOutput(V, destSgmacGroupId_f, &lag_ouput))

        if (GetDbgLagEngineInfo(V, dbgCflexSlbEn_f, lag_info))
        {
            DIAG_INFO_CHAR(pos, "trunk-mode", "STATIC")
            DIAG_INFO_UINT32(pos, "hash-value", GetDbgLagEngineInfo(V, debugCflexHash_f, lag_info))
        }
        else if (GetDbgLagEngineInfo(V, dbgCflexRrEn_f, lag_info))
        {
            DIAG_INFO_CHAR(pos, "trunk-mode", "RR")
        }
        else if (GetDbgLagEngineInfo(V, dbgCflexDlbEn_f, lag_info))
        {
            DIAG_INFO_CHAR(pos, "trunk-mode", "DLB")
            DIAG_INFO_UINT32(pos, "hash-value", GetDbgLagEngineInfo(V, debugCflexHash_f, lag_info))
        }
        else if (GetDbgLagEngineInfo(V, dbgCflexRhEn_f, lag_info))
        {
            DIAG_INFO_CHAR(pos, "trunk-mode", "RH")
            DIAG_INFO_UINT32(pos, "hash-value", GetDbgLagEngineInfo(V, debugCflexHash_f, lag_info))
        }

        if (GetDbgLagEngineInfo(V, dbgCflexLshEn_f, lag_info))
        {
            DIAG_INFO_CHAR(pos, "link self healing", "ENABLE")
            DIAG_INFO_UINT32(pos, "lsh-hash-value", GetDbgLagEngineInfo(V, debugCflexLshHash_f, lag_info))
        }

        p_rslt->tid = GetLagEngineOutput(V, destSgmacGroupId_f, &lag_ouput);
        p_rslt->flags |= CTC_DIAG_TRACE_RSTL_FLAG_TID;
    }
    else if (GetDbgLagEngineInfo(V, chanLagEnable_f, lag_info) || GetDbgLagEngineInfo(V, portLagEnable_f, lag_info))
    {
        if (GetDbgLagEngineInfo(V, chanLagEnable_f, lag_info))
        {
            DIAG_INFO_CHAR(pos, "Linkagg Process", "channel-linkagg")
        }
        else
        {
            DIAG_INFO_CHAR(pos, "Linkagg Process", "port-linkagg")
        }

        DIAG_INFO_UINT32(pos, "linkagg-id", GetIpeToLagEngineInput(V, destMap_f, &ipe_lag_input) & CTC_LINKAGGID_MASK)

        if (GetDbgLagEngineInfo(V, dbgPLagSlbEn_f, lag_info))
        {
            DIAG_INFO_CHAR(pos, "linkagg-mode", "STATIC")
            DIAG_INFO_UINT32(pos, "hash-value", GetDbgLagEngineInfo(V, debugPortLagHash_f, lag_info))
        }
        else if (GetDbgLagEngineInfo(V, dbgPLagRrEn_f, lag_info))
        {
            DIAG_INFO_CHAR(pos, "linkagg-mode", "RR")
        }
        else if (GetDbgLagEngineInfo(V, dbgPLagDlbEn_f, lag_info))
        {
            DIAG_INFO_CHAR(pos, "linkagg-mode", "DLB")
            DIAG_INFO_UINT32(pos, "hash-value", GetDbgLagEngineInfo(V, debugPortLagHash_f, lag_info))
        }
        else if (GetDbgLagEngineInfo(V, dbgPLagRhEn_f, lag_info))
        {
            DIAG_INFO_CHAR(pos, "linkagg-mode", "RH")
            DIAG_INFO_UINT32(pos, "hash-value", GetDbgLagEngineInfo(V, debugPortLagHash_f, lag_info))
        }
        else if (GetDbgLagEngineInfo(V, dbgPLagLmpfEn_f, lag_info))
        {
            DIAG_INFO_CHAR(pos, "linkagg-mode", "LMPF")
            DIAG_INFO_UINT32(pos, "hash-value", GetDbgLagEngineInfo(V, debugPortLagHash_f, lag_info))
        }

        if (GetDbgLagEngineInfo(V, dbgPLagLshEn_f, lag_info))
        {
            DIAG_INFO_CHAR(pos, "link self healing", "ENABLE")
            DIAG_INFO_UINT32(pos, "lsh-hash-value", GetDbgLagEngineInfo(V, debugPortLagLshHash_f, lag_info))
        }

        if (GetDbgLagEngineInfo(V, antFlowEn_f, lag_info))
        {
            DIAG_INFO_CHAR(pos, "antFlowEn", "ENABLE")
            DIAG_INFO_UINT32(pos, "active", GetDbgLagEngineInfo(V, antFlowActive_f, lag_info))
            DIAG_INFO_UINT32(pos, "link-state", GetDbgLagEngineInfo(V, antFlowLinkState_f, lag_info))
            DIAG_INFO_UINT32(pos, "path-valid", GetDbgLagEngineInfo(V, antFlowPathValid_f, lag_info))
            DIAG_INFO_UINT32(pos, "agingPtr", GetDbgLagEngineInfo(V, agingPtr_f, &lag_ouput))
            DIAG_INFO_U32_HEX(pos, "record-info", GetDbgLagEngineInfo(V, antFlowRecordInfo_f, lag_info))
//              DIAG_INFO_UINT32(pos, "srv-hash-value", GetDbgLagEngineInfo(V, antFlowHash_f, lag_info))
        }

        p_rslt->tid = GetIpeToLagEngineInput(V, destMap_f, &ipe_lag_input) & CTC_LINKAGGID_MASK;
        p_rslt->flags |= CTC_DIAG_TRACE_RSTL_FLAG_TID;
    }

    if (GetLagEngineOutput(V, destChannelIdValid_f, &lag_ouput))
    {
        DIAG_INFO_UINT32(pos, "dest-slice", GetLagEngineOutput(V, destSliceId_f, &lag_ouput))
        DIAG_INFO_UINT32(pos, "dest-channel", GetLagEngineOutput(V, destChannelId_f, &lag_ouput))
    }
    DIAG_INFO_U32_HEX(pos, "dest-map", GetLagEngineOutput(V, updateDestMap_f, &lag_ouput))

    return CTC_E_NONE;
}

STATIC int32
_sys_at_diag_pkt_trace_get_ipe_phb_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    DbgIpePerHopBehaviorInfo_m dbg_phb_info;
    char *sys_diag_color[] = {"None", "Red", "Yellow", "Green"};

    /*phb process*/
    sal_memset(&dbg_phb_info, 0, sizeof(DbgIpePerHopBehaviorInfo_m));
    cmd = DRV_IOR(DbgIpePerHopBehaviorInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &dbg_phb_info));

    if(GetDbgIpePerHopBehaviorInfo(V, valid_f, &dbg_phb_info))
    {
        p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
        DIAG_INFO_NONE(pos, "Per-hop Behavior")
        DIAG_INFO_CHAR(pos, "phb-color", sys_diag_color[GetDbgIpePerHopBehaviorInfo(V, color_f, &dbg_phb_info)])
        DIAG_INFO_UINT32(pos, "phb-prio", GetDbgIpePerHopBehaviorInfo(V, prio_f, &dbg_phb_info))
        DIAG_INFO_UINT32(pos, "phb-classified-cfi", GetDbgIpePerHopBehaviorInfo(V, classifiedCfi_f, &dbg_phb_info))
        DIAG_INFO_UINT32(pos, "phb-classified-cos", GetDbgIpePerHopBehaviorInfo(V, classifiedCos_f, &dbg_phb_info))
        DIAG_INFO_UINT32(pos, "phb-classified-dscp", GetDbgIpePerHopBehaviorInfo(V, classifiedDscp_f, &dbg_phb_info))
        DIAG_INFO_UINT32(pos, "phb-classified-tc", GetDbgIpePerHopBehaviorInfo(V, classifiedTc_f, &dbg_phb_info))
        if (GetDbgIpePerHopBehaviorInfo(V, srcDscpValid_f, &dbg_phb_info))
        {
            DIAG_INFO_UINT32(pos, "phb-src-dscp",  GetDbgIpePerHopBehaviorInfo(V, srcDscp_f, &dbg_phb_info))
        }
    }

    return CTC_E_NONE;
}

STATIC int32
_sys_at_diag_pkt_trace_get_ipe_oam_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint8  idx = 0;
    uint32 value = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    char* lookup_result[4] = {"ETHER", "BFD", "TP", "Section"};
    char* key_name[4] = {"DsOamEthHashKey", "DsOamBfdHashKey",
                         "DsOamMplsLabelHashKey", "DsOamMplsSectionHashKey"};
    char *sys_diag_color[] = {"None", "Red", "Yellow", "Green"};
    DbgOamHashEngineFromIpeOam0Info_m oam0_info;
    DbgOamHashEngineFromIpeOam1Info_m oam1_info;
    DbgOamHashEngineFromIpeOam2Info_m oam2_info;
    DbgIpeLkpMgrInfo_m lkp_mgr_info;
    DbgIpeOamInfo_m ipe_oam_info;
    uint8 key_type[3] = {0};
    uint8 hash_valid[3] = {0};
    uint8 confict[3] = {0};
    uint32 key_index[3] = {0};
    uint8 hash_resultValid[3] = {0};

    sal_memset(&oam0_info, 0, sizeof(oam0_info));
    cmd = DRV_IOR(DbgOamHashEngineFromIpeOam0Info_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &oam0_info));
    sal_memset(&oam1_info, 0, sizeof(oam1_info));
    cmd = DRV_IOR(DbgOamHashEngineFromIpeOam1Info_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &oam1_info));
    sal_memset(&oam2_info, 0, sizeof(oam2_info));
    cmd = DRV_IOR(DbgOamHashEngineFromIpeOam2Info_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &oam2_info));
    sal_memset(&lkp_mgr_info, 0, sizeof(lkp_mgr_info));
    cmd = DRV_IOR(DbgIpeLkpMgrInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &lkp_mgr_info));
    sal_memset(&ipe_oam_info, 0, sizeof(ipe_oam_info));
    cmd = DRV_IOR(DbgIpeOamInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &ipe_oam_info));

    key_type[0] = GetDbgIpeLkpMgrInfo(V, ingressOamKeyType0_f, &lkp_mgr_info);
    key_type[1] = GetDbgIpeLkpMgrInfo(V, ingressOamKeyType1_f, &lkp_mgr_info);
    key_type[2] = GetDbgIpeLkpMgrInfo(V, ingressOamKeyType2_f, &lkp_mgr_info);

    hash_resultValid[0] = GetDbgOamHashEngineFromIpeOam0Info(V, resultValid_f, &oam0_info);
    confict[0] = GetDbgOamHashEngineFromIpeOam0Info(V, hashConflict_f, &oam0_info);
    key_index[0] = GetDbgOamHashEngineFromIpeOam0Info(V, keyIndex_f, &oam0_info);
    hash_valid[0] = GetDbgOamHashEngineFromIpeOam0Info(V, valid_f, &oam0_info);

    hash_resultValid[1] = GetDbgOamHashEngineFromIpeOam1Info(V, resultValid_f, &oam1_info);
    confict[1] = GetDbgOamHashEngineFromIpeOam1Info(V, hashConflict_f, &oam1_info);
    key_index[1] = GetDbgOamHashEngineFromIpeOam1Info(V, keyIndex_f, &oam1_info);
    hash_valid[1] = GetDbgOamHashEngineFromIpeOam1Info(V, valid_f, &oam1_info);

    hash_resultValid[2] = GetDbgOamHashEngineFromIpeOam2Info(V, resultValid_f, &oam2_info);
    confict[2] = GetDbgOamHashEngineFromIpeOam2Info(V, hashConflict_f, &oam2_info);
    key_index[2] = GetDbgOamHashEngineFromIpeOam2Info(V, keyIndex_f, &oam2_info);
    hash_valid[2] = GetDbgOamHashEngineFromIpeOam2Info(V, valid_f, &oam2_info);

    if (!GetDbgIpeOamInfo(V, valid_f, &ipe_oam_info))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
    DIAG_INFO_NONE(pos, "IPE OAM")
    if (key_type[0] || key_type[1] || key_type[2])
    {
        char str[64] = {0};
        DIAG_INFO_CHAR(pos, "dm-en", GetDbgIpeOamInfo(V, dmEn_f, &ipe_oam_info)? DIAG_ENABLE: DIAG_DISABLE)
        cmd = DRV_IOR(IpeOamCtl_t, IpeOamCtl_oamPriMapEn_f);
        CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &value));
        if (value)
        {
            DIAG_INFO_UINT32(pos, "prio", GetDbgIpeOamInfo(V, dmEn_f, &ipe_oam_info))
            DIAG_INFO_CHAR(pos, "color", sys_diag_color[GetDbgIpeOamInfo(V, dmEn_f, &ipe_oam_info)])
        }
        for (idx = 0; idx < 3; idx++)
        {
            if (!key_type[idx] || !hash_valid[idx])
            {
                continue;
            }
            /*OAMHASHTYPE_ETH = 0x1*/
            value = key_type[idx] -0x1 ;
            sal_sprintf(str, "hash-%d", idx);
            DIAG_INFO_CHAR(pos, str, lookup_result[value])
            if (confict[idx])
            {
                DIAG_INFO_CHAR(pos, "lookup-result", DIAG_LOOKUP_CONFLICT)
                DIAG_INFO_CHAR(pos, "key-name", key_name[value])
                DIAG_INFO_UINT32(pos, "key-index", key_index[idx])
            }
            else if (hash_resultValid[idx])
            {
                DIAG_INFO_CHAR(pos, "lookup-result", DIAG_LOOKUP_HIT)
                DIAG_INFO_CHAR(pos, "key-name", key_name[value])
                DIAG_INFO_UINT32(pos, "key-index", key_index[idx])
            }
            else
            {
                DIAG_INFO_CHAR(pos, "lookup-result", DIAG_LOOKUP_HIT_NONE)
            }
        }
    }

    if (hash_resultValid[0] || hash_resultValid[1] || hash_resultValid[2])
    {
        value = GetDbgIpeOamInfo(V, tempRxOamType_f, &ipe_oam_info);
        if (value)
        {
            /*RXOAMTYPE_TRILLBFD = 0xa*/
            char* oam_type[10] =
            {
                "ETHER OAM", "IP BFD", "PBT OAM", "PBBBSI", "PBBBV",
                "MPLS OAM", "MPLS BFD", "ACH OAM", "RSV", "TRILL BFD"
            };
            DIAG_INFO_CHAR(pos, "oam-type", oam_type[value - 1])
        }

        value = GetDbgIpeOamInfo(V, oamDestChipId_f, &ipe_oam_info);
        if (GetDbgIpeOamInfo(V, mepEn_f, &ipe_oam_info))
        {
            DIAG_INFO_CHAR(pos, "MEP", "HIT")
            DIAG_INFO_UINT32(pos, "master-chip-id", value)
            DIAG_INFO_UINT32(pos, "master-slice-id", GetDbgIpeOamInfo(V, oamDestSliceId_f, &ipe_oam_info))
            DIAG_INFO_UINT32(pos, "mep-index", GetDbgIpeOamInfo(V, mepIndex_f, &ipe_oam_info))
        }
        if (GetDbgIpeOamInfo(V, mipEn_f, &ipe_oam_info))
        {
            DIAG_INFO_CHAR(pos, "MIP", "HIT")
            DIAG_INFO_UINT32(pos, "master-chip-id", value)
        }

        if (GetDbgIpeOamInfo(V, mplsLmValid_f, &ipe_oam_info) || GetDbgIpeOamInfo(V, etherLmValid_f, &ipe_oam_info))
        {
            DIAG_INFO_CHAR(pos, "action", "read-LM")
            DIAG_INFO_CHAR(pos, "table-name", "DsOamLmStats")
            DIAG_INFO_UINT32(pos, "table-index", GetDbgIpeOamInfo(V, lmStatsIndex_f, &ipe_oam_info))

        }
        if (GetDbgIpeOamInfo(V, lmStatsEn0_f, &ipe_oam_info))
        {
            DIAG_INFO_CHAR(pos, "action", "write-LM")
            DIAG_INFO_CHAR(pos, "table-name", "DsOamLmStats")
            DIAG_INFO_UINT32(pos, "table-index", GetDbgIpeOamInfo(V, lmStatsPtr0_f, &ipe_oam_info))
        }
        if (GetDbgIpeOamInfo(V, lmStatsEn1_f, &ipe_oam_info))
        {
            DIAG_INFO_CHAR(pos, "action", "write-LM")
            DIAG_INFO_CHAR(pos, "table-name", "DsOamLmStats")
            DIAG_INFO_UINT32(pos, "table-index", GetDbgIpeOamInfo(V, lmStatsPtr1_f, &ipe_oam_info))
        }
        if (GetDbgIpeOamInfo(V, lmStatsEn2_f, &ipe_oam_info))
        {
            DIAG_INFO_CHAR(pos, "action", "write-LM")
            DIAG_INFO_CHAR(pos, "table-name", "DsOamLmStats")
            DIAG_INFO_UINT32(pos, "table-index", GetDbgIpeOamInfo(V, lmStatsPtr2_f, &ipe_oam_info))
        }
    }

    /* Exception Process */
    _sys_at_diag_pkt_tracce_exception_map(lchip,p_rslt,
                                           GetDbgIpeOamInfo(V, exceptionEn_f, &ipe_oam_info),
                                           GetDbgIpeOamInfo(V, exceptionIndex_f, &ipe_oam_info),
                                           GetDbgIpeOamInfo(V, exceptionSubIndex_f, &ipe_oam_info));

    return CTC_E_NONE;
}

STATIC int32
_sys_at_diag_pkt_trace_get_oam_rx_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_OAM;
    char* oam_pdu_type[40] = {"OAM-TYPE-NONE", "ETHER-CCM", "ETHER-APS", "ETHER-1DM", "ETHER-DMM",
                          "ETHER-DMR", "ETHER-RAPS", "ETHER-LBM", "ETHER-LBR", "ETHER-LMR",
                          "ETHER-LMM", "MPLSTP-LBM", "ETHER-TST", "ETHER-LTR", "ETHER-LTM",
                          "ETHER-OTHER", "MPLSTP-DM", "MPLSTP-DLM", "MPLSTP-DLMDM", "MPLSTP-CV",
                          "MPLSTP-CSF", "ETHER-CSF", "ETHER-MCC", "MPLS-OTHER", "MPLSTP-MCC",
                          "MPLSTP-FM", "ETHER-SLM", "ETHER-SLR", "MPLS-OAM", "BFD-OAM",
                          "ETHER-SCC", "MPLSTP-SCC", "FLEX-TEST", "TWAMP", "ETHER-1SL",
                          "ETHER-LLM", "ETHER-LLR", "ETHER-SCM", "ETHER-SCR"};

    DbgOamHdrAdj_m  oam_hdr_adj;
    DbgOamParser_m   oam_parser;
    DbgOamRxProc_m  oam_rx_proc;
    DbgOamDefectProc_m  oam_defect_proc;
    DbgOamHdrEdit_m     oam_hdr_edit;
    DbgOamApsSwitch_m oam_aps_switch;
    DbgOamApsProcess_m oam_aps_proc;
    DbgOamRmepHashInfo_m oam_rmep_hash_info;

    sal_memset(&oam_hdr_adj, 0, sizeof(oam_hdr_adj));
    cmd = DRV_IOR(DbgOamHdrAdj_t, DRV_ENTRY_FLAG);
    CTC_ERROR_DUMP(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &oam_hdr_adj));

    sal_memset(&oam_parser, 0, sizeof(oam_parser));
    cmd = DRV_IOR(DbgOamParser_t, DRV_ENTRY_FLAG);
    CTC_ERROR_DUMP(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &oam_parser));

    sal_memset(&oam_rx_proc, 0, sizeof(oam_rx_proc));
    cmd = DRV_IOR(DbgOamRxProc_t, DRV_ENTRY_FLAG);
    CTC_ERROR_DUMP(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &oam_rx_proc));

    sal_memset(&oam_defect_proc, 0, sizeof(oam_defect_proc));
    cmd = DRV_IOR(DbgOamDefectProc_t, DRV_ENTRY_FLAG);
    CTC_ERROR_DUMP(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &oam_defect_proc));

    sal_memset(&oam_hdr_edit, 0, sizeof(oam_hdr_edit));
    cmd = DRV_IOR(DbgOamHdrEdit_t, DRV_ENTRY_FLAG);
    CTC_ERROR_DUMP(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &oam_hdr_edit));

    sal_memset(&oam_aps_switch, 0, sizeof(oam_aps_switch));
    cmd = DRV_IOR(DbgOamApsSwitch_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &oam_aps_switch));

    sal_memset(&oam_aps_proc, 0, sizeof(oam_aps_proc));
    cmd = DRV_IOR(DbgOamApsProcess_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &oam_aps_proc));

    sal_memset(&oam_rmep_hash_info, 0, sizeof(oam_rmep_hash_info));
    cmd = DRV_IOR(DbgOamRmepHashInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_DUMP(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &oam_rmep_hash_info));

    if (!(GetDbgOamApsSwitch(V, valid_f, &oam_aps_switch)
           || GetDbgOamHdrEdit(V, valid_f, &oam_hdr_edit)
           || GetDbgOamDefectProc(V, valid_f, &oam_defect_proc)
           || GetDbgOamRxProc(V, valid_f, &oam_rx_proc)
           || GetDbgOamParser(V, valid_f, &oam_parser)
           || GetDbgOamHdrAdj(V, valid_f, &oam_hdr_adj)))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_OAM;
    DIAG_INFO_NONE(pos, "OAM RX Process")

    if (GetDbgOamHdrEdit(V, bypassAll_f, &oam_hdr_edit)
        || GetDbgOamRxProc(V, bypassAll_f, &oam_rx_proc))
    {
        DIAG_INFO_CHAR(pos, "oam-edit", "bypass-all")
    }
    if (GetDbgOamHdrEdit(V, discard_f, &oam_hdr_edit))
    {
        p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        DIAG_INFO_CHAR(pos, "discard", "TURE")
    }

    if (GetDbgOamHdrEdit(V, exception_f, &oam_hdr_edit))
    {
        p_rslt->dest_type = CTC_DIAG_DEST_CPU;
        DIAG_INFO_UINT32(pos, "exception-id", GetDbgOamHdrEdit(V, exception_f, &oam_hdr_edit))
    }

    /*oam parser*/
    if (GetDbgOamParser(V, oamPduInvalid_f, &oam_parser) || GetDbgOamParser(V, bfdOamPduInvalid_f, &oam_parser))
    {
        DIAG_INFO_CHAR(pos, "oam-pdu-type", oam_pdu_type[GetDbgOamParser(V, oamType_f, &oam_parser)])

        if (GetDbgOamParser(V, bfdOamPduInvalid_f, &oam_parser))
        {
            DIAG_INFO_UINT32(pos, "dbit", GetDbgOamParser(V, u_bfd_dbit_f, &oam_parser))
            DIAG_INFO_UINT32(pos, "my-disc", GetDbgOamParser(V, u_bfd_myDisc_f, &oam_parser))
            DIAG_INFO_UINT32(pos, "your-disc", GetDbgOamParser(V, u_bfd_yourDisc_f, &oam_parser))
            DIAG_INFO_UINT32(pos, "desired-min-tx-interval", GetDbgOamParser(V, u_bfd_desiredMinTxInterval_f, &oam_parser))
            DIAG_INFO_UINT32(pos, "required-min-rx-interval", GetDbgOamParser(V, u_bfd_requiredMinRxInterval_f, &oam_parser))

            /*mpls-tp*/
            DIAG_INFO_UINT32(pos, "mpls-tp-dflags", GetDbgOamParser(V, u_tp_dflags_f, &oam_parser))
            DIAG_INFO_UINT32(pos, "mpls-tp-csflags", GetDbgOamParser(V, u_tp_csfFlags_f, &oam_parser))

            /*twamp*/
            DIAG_INFO_UINT32(pos, "seqnum", GetDbgOamParser(V, u_twamp_seqNum_f, &oam_parser))
            DIAG_INFO_UINT32(pos, "sender-seqnum", GetDbgOamParser(V, u_twamp_senderSeqNum_f, &oam_parser))
            DIAG_INFO_UINT32(pos, "err-est-sbit", GetDbgOamParser(V, u_twamp_errEstSbit_f, &oam_parser))
            DIAG_INFO_UINT32(pos, "err-est-zbit", GetDbgOamParser(V, u_twamp_errEstZbit_f, &oam_parser))
            DIAG_INFO_UINT32(pos, "err-est-scale", GetDbgOamParser(V, u_twamp_errEstScale_f, &oam_parser))
            DIAG_INFO_UINT32(pos, "err-est-mult", GetDbgOamParser(V, u_twamp_errEstMult_f, &oam_parser))
        }
        else if(GetDbgOamParser(V, oamPduInvalid_f, &oam_parser))
        {
            DIAG_INFO_UINT32(pos, "md-level", GetDbgOamParser(V, u_ethoam_mdlevel_f, &oam_parser))
        }
    }

    /*oam rx proc*/
    if (GetDbgOamRxProc(V, valid_f, &oam_rx_proc))
    {
        DIAG_INFO_UINT32(pos, "mep-index", GetDbgOamRxProc(V, mepIndex_f, &oam_rx_proc))
        DIAG_INFO_UINT32(pos, "ma-index", GetDbgOamRxProc(V, maIndex_f, &oam_rx_proc))
        DIAG_INFO_UINT32(pos, "rmep-index", GetDbgOamRxProc(V, rmepIndex_f, &oam_rx_proc))

        DIAG_INFO_UINT32(pos, "Rx-exception", GetDbgOamRxProc(V, exception_f, &oam_rx_proc))
        if (GetDbgOamRxProc(V, linkOam_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "LinkOAM", "YES")
        }
        if (GetDbgOamRxProc(V, lowCcm_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "LowCCM", "YES")
        }
        if (GetDbgOamRxProc(V, lowSlowOam_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "LowSlowCCM", "YES")
        }
        if (GetDbgOamRxProc(V, mipEn_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "MipEn", "YES")
        }

        if (GetDbgOamRxProc(V, equalBfd_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "BFD-Proc", "YES")
        }
        if (GetDbgOamRxProc(V, equalCcm_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "CCM-Proc", "YES")
        }
        if (GetDbgOamRxProc(V, equalDm_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "DM-Proc", "YES")
        }
        if (GetDbgOamRxProc(V, equalEthTst_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "Tst-Proc", "YES")
        }
        if (GetDbgOamRxProc(V, equalFlexTest_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "FlexTest-Proc", "YES")
        }
        if (GetDbgOamRxProc(V, equalLb_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "LB-Proc", "YES")
        }
        if (GetDbgOamRxProc(V, equalLm_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "LM-Proc", "YES")
        }
        if (GetDbgOamRxProc(V, equalSm_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "SM-Proc", "YES")
        }
        if (GetDbgOamRxProc(V, equalTwamp_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "TWAMP-Proc", "YES")
        }
        if (GetDbgOamRxProc(V, equalSBfdReflector_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "SBFD-Ref-Proc", "YES")
        }
        if (GetDbgOamRxProc(V, sBfdInitiatorRxEn_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "SBFD-Ini-Proc", "YES")
        }
        if (GetDbgOamRxProc(V, isMdLvlMatch_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "Md-Lvl-Match", "YES")
        }
        if (GetDbgOamRxProc(V, isUp_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "is-up", "YES")
        }
    }

    if ( GetDbgOamDefectProc(V, valid_f, &oam_defect_proc)
        && (GetDbgOamDefectProc(V, defectSubType_f, &oam_defect_proc)
            || GetDbgOamDefectProc(V, defectType_f, &oam_defect_proc)))
    {
        DIAG_INFO_UINT32(pos, "oam-defect-type", GetDbgOamDefectProc(V, defectType_f, &oam_defect_proc))
        DIAG_INFO_UINT32(pos, "oam-defect-sub-type", GetDbgOamDefectProc(V, defectSubType_f, &oam_defect_proc))
    }

   /*rmep hash info*/
    if (GetDbgOamRmepHashInfo(V, valid_f, &oam_rmep_hash_info) && GetDbgOamRmepHashInfo(V, resultValid_f, &oam_rmep_hash_info))
    {
        DIAG_INFO_CHAR(pos, "oam-rmep-lookup-result", DIAG_LOOKUP_HIT)
        DIAG_INFO_CHAR(pos, "key-name", (GetDbgOamRmepHashInfo(V, hashConflict_f, &oam_rmep_hash_info) ? "DsEthOamRmepHashCam" : "DsEthOamRmepRmepHashKey"))
        DIAG_INFO_UINT32(pos, "key-index", GetDbgOamRmepHashInfo(V, keyIndex_f, &oam_rmep_hash_info))
        DIAG_INFO_UINT32(pos, "mep-index", GetDbgOamRmepHashInfo(V, mepIndex_f, &oam_rmep_hash_info))
        DIAG_INFO_UINT32(pos, "rmep-Id", GetDbgOamRmepHashInfo(V, rmepId_f, &oam_rmep_hash_info))
    }

    /*oam head edit*/
    if (GetDbgOamHdrEdit(V, bypassAll_f, &oam_hdr_edit))
    {
        DIAG_INFO_CHAR(pos, "oam-header-edit-process", "bypass-all")
    }
    if (GetDbgOamHdrEdit(V, isDefectFree_f, &oam_hdr_edit))
    {
        DIAG_INFO_CHAR(pos, "oam-header-edit-process", "no-defect")
    }
    if (GetDbgOamHdrEdit(V, discard_f, &oam_hdr_edit))
    {
        DIAG_INFO_CHAR(pos, "oam-header-edit-process", "discard")
    }
    if (GetDbgOamHdrEdit(V, equalDm_f, &oam_hdr_edit))
    {
        DIAG_INFO_CHAR(pos, "oam-header-edit-process", "DM-Proc")
    }
    if (GetDbgOamHdrEdit(V, equalLb_f, &oam_hdr_edit))
    {
        DIAG_INFO_CHAR(pos, "oam-header-edit-process", "LB-Proc")
    }
    if (GetDbgOamHdrEdit(V, equalLm_f, &oam_hdr_edit))
    {
        DIAG_INFO_CHAR(pos, "oam-header-edit-process", "LM-Proc")
    }
    if (GetDbgOamHdrEdit(V, equalSm_f, &oam_hdr_edit))
    {
        DIAG_INFO_CHAR(pos, "oam-header-edit-process", "SM-Proc")
    }
    if (GetDbgOamHdrEdit(V, equalTwamp_f, &oam_hdr_edit))
    {
        DIAG_INFO_CHAR(pos, "oam-header-edit-process", "TWAMP-Proc")
    }
    if (GetDbgOamHdrEdit(V, twampAck_f, &oam_hdr_edit))
    {
        DIAG_INFO_CHAR(pos, "oam-header-edit-process", "TWAMP-ACK-Proc")
    }
    if (GetDbgOamHdrEdit(V, equalSBfdReflector_f, &oam_hdr_edit))
    {
        DIAG_INFO_CHAR(pos, "oam-header-edit-process", "SBFD-Proc")
    }
#if 0
    if (GetDbgOamHdrEdit(V, oamHdrEditEqualPeriodTest_f, &oam_hdr_edit))
    {
        DIAG_INFO_CHAR(pos, "oam-header-edit-process", "NPM-LITE")
    }
#endif
    if (GetDbgOamApsSwitch(V, valid_f, &oam_aps_switch))
    {
        DIAG_INFO_UINT32(pos, "aps-group", GetDbgOamApsSwitch(V, apsGroupId_f, &oam_aps_switch))
        if (GetDbgOamApsSwitch(V, signalOk_f, &oam_aps_switch))
        {
            DIAG_INFO_CHAR(pos, "aps-switch-signal", "OK")
        }
        if (GetDbgOamApsSwitch(V, signalFail_f, &oam_aps_switch))
        {
            DIAG_INFO_CHAR(pos, "aps-switch-signal", "FAIL")
        }
        if (GetDbgOamApsSwitch(V, protectionFail_f, &oam_aps_switch))
        {
            DIAG_INFO_CHAR(pos, "aps-switch-protection", "FAIL")
        }
        if (GetDbgOamApsSwitch(V, workingFail_f, &oam_aps_switch))
        {
            DIAG_INFO_CHAR(pos, "aps-switch-working", "FAIL")
        }
    }
    else if (!GetDbgOamApsSwitch(V, valid_f, &oam_aps_switch)
            && GetDbgOamApsProcess(V, valid_f, &oam_aps_proc))
    {
        if (GetDbgOamApsProcess(V, signalOk_f, &oam_aps_proc))
        {
            DIAG_INFO_CHAR(pos, "aps-process-signal", "OK")
        }
        if (GetDbgOamApsProcess(V, signalFail_f, &oam_aps_proc))
        {
            DIAG_INFO_CHAR(pos, "aps-process-signal", "FAIL")
        }
        if (GetDbgOamApsProcess(V, updateApsEn_f, &oam_aps_proc))
        {
            DIAG_INFO_CHAR(pos, "aps-process-update", "ENABLE")
        }
    }

    p_rslt->dest_type = CTC_DIAG_DEST_OAM;
    return CTC_E_NONE;
}

STATIC int32
_sys_at_diag_pkt_trace_get_oam_tx_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_OAM;
    char* rx_oam_type[15] = {"NONE", "ETHEROAM", "IPBFD", "PBTOAM", "PBBBSI",
                          "PBBBV", "MPLSOAM", "MPLSBFD", "ACHOAM", "TRILLBFD",
                          "TWAMP", "FLEX_PM_TEST"};
    char* packet_type[10] = {"ETHERNET", "IPV4", "MPLS", "IPV6", "MPLSUP",
                          "IP", "FLEXIBLE", "RESERVED"};
    DbgOamTxProc_m   oam_tx_proc;

    sal_memset(&oam_tx_proc, 0, sizeof(oam_tx_proc));
    cmd = DRV_IOR(DbgOamTxProc_t, DRV_ENTRY_FLAG);
    CTC_ERROR_DUMP(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &oam_tx_proc));

    if (!GetDbgOamTxProc(V, valid_f, &oam_tx_proc))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_OAM;
    DIAG_INFO_NONE(pos, "OAM TX Process")

    DIAG_INFO_CHAR(pos, "tx-oam-type", rx_oam_type[GetDbgOamTxProc(V, rxOamType_f, &oam_tx_proc)])
    DIAG_INFO_CHAR(pos, "packet-type", packet_type[GetDbgOamTxProc(V, packetType_f, &oam_tx_proc)])
    DIAG_INFO_UINT32(pos, "nexthop-ptr", GetDbgOamTxProc(V, nextHopPtr_f, &oam_tx_proc))
    DIAG_INFO_U32_HEX(pos, "dest-map", GetDbgOamTxProc(V, destMap_f, &oam_tx_proc))

    if (GetDbgOamTxProc(V, isEth_f, &oam_tx_proc))
    {
        DIAG_INFO_CHAR(pos, "is-Eth", "YES")
    }
    if (GetDbgOamTxProc(V, isTxCv_f, &oam_tx_proc))
    {
        DIAG_INFO_CHAR(pos, "is-TxCv", "YES")
    }
    if (GetDbgOamTxProc(V, isTxCsf_f, &oam_tx_proc))
    {
        DIAG_INFO_CHAR(pos, "is-TxCsf", "YES")
    }
    if (GetDbgOamTxProc(V, isUp_f, &oam_tx_proc))
    {
        DIAG_INFO_CHAR(pos, "is-UpMep", "YES")
    }
#if 0

    if (GetDbgOamTxProc(V, oamTxProcIsTxPeriodTest_f, &oam_tx_proc))
    {
        DIAG_INFO_CHAR(pos, "is-Npm-Lite", "YES")
    }
#endif
    p_rslt->dest_type = CTC_DIAG_DEST_OAM;
    return CTC_E_NONE;
}


STATIC int32
_sys_at_diag_pkt_trace_get_ipe_cid_pair_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 value = 0;
    uint32 cmd = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    char*  str_hash_key_name[] = {"DsCategoryIdPairHashRightKey", "DsCategoryIdPairHashLeftKey"};
    char*  str_hash_ad_name[] = {"DsCategoryIdPairHashRightAd", "DsCategoryIdPairHashLeftAd"};
    DbgIpeAclProcInfo0_m   acl_info;
    DsCategoryIdPair_m     ds_cid_pair;

    sal_memset(&ds_cid_pair, 0, sizeof(DsCategoryIdPair_m));
    sal_memset(&acl_info, 0, sizeof(DbgIpeAclProcInfo0_m));

    cmd = DRV_IOR(IpeFwdCategoryCtl_t, IpeFwdCategoryCtl_categoryIdPairLookupEn_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &value));
    if (!value)
    {
        return CTC_E_NONE;
    }

    cmd = DRV_IOR(DbgIpeAclProcInfo0_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &acl_info));

    if(GetDbgIpeAclProcInfo0(V, gCidLkp_srcCategoryIdClassfied_f , &acl_info))
    {
        DIAG_INFO_UINT32(pos, "source-category-id", GetDbgIpeAclProcInfo0(V, gCidLkp_srcCategoryId_f, &acl_info))
    }

    if(GetDbgIpeAclProcInfo0(V, gCidLkp_destCategoryIdClassfied_f, &acl_info))
    {
        DIAG_INFO_UINT32(pos, "dest-category-id", GetDbgIpeAclProcInfo0(V, gCidLkp_destCategoryId_f, &acl_info))
    }

    if (GetDbgIpeAclProcInfo0(V, gCidLkp_cidPairHashHit_f, &acl_info))
    {
        value = GetDbgIpeAclProcInfo0(V, gCidLkp_cidPairHashIsLeft_f, &acl_info);
        DIAG_INFO_CHAR(pos, "cid-lookup-result", "HIT-HASH")

        DIAG_INFO_CHAR(pos, "key-name", str_hash_key_name[value])
        DIAG_INFO_UINT32(pos, "key-index", GetDbgIpeAclProcInfo0(V, gCidLkp_cidPairHashKeyIndex_f, &acl_info))
        DIAG_INFO_CHAR(pos, "ad-name", str_hash_ad_name[value])
        DIAG_INFO_UINT32(pos, "ad-index", GetDbgIpeAclProcInfo0(V, gCidLkp_cidPairHashAdIndex_f, &acl_info))
        DIAG_INFO_UINT32(pos, "array-offset", GetDbgIpeAclProcInfo0(V, gCidLkp_cidPairHashEntryOffset_f, &acl_info))
        if(value)
        {
            cmd = DRV_IOR(DsCategoryIdPairHashRightAd_t, DRV_ENTRY_FLAG);
        }
        else
        {
            cmd = DRV_IOR(DsCategoryIdPairHashLeftAd_t, DRV_ENTRY_FLAG);
        }
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, GetDbgIpeAclProcInfo0(V, gCidLkp_cidPairHashAdIndex_f, &acl_info), DRV_CMD_PP_EN(cmd), &ds_cid_pair));
    }
    else if (GetDbgIpeAclProcInfo0(V, gCidLkp_cidPairTcamResultValid_f , &acl_info))
    {
        value = GetDbgIpeAclProcInfo0(V, gCidLkp_cidPairTcamHitIndex_f, &acl_info);
        DIAG_INFO_CHAR(pos, "cid-lookup-result", "HIT-TCAM")
        DIAG_INFO_CHAR(pos, "key-name", "DsCategoryIdPairTcamKey")
        DIAG_INFO_UINT32(pos, "key-index", value)
        DIAG_INFO_CHAR(pos, "ad-name", "DsCategoryIdPairTcamAd")
        DIAG_INFO_UINT32(pos, "ad-index", value)
        cmd = DRV_IOR(DsCategoryIdPairTcamAd_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, value, DRV_CMD_PP_EN(cmd), &ds_cid_pair));
    }
    else
    {
        DIAG_INFO_CHAR(pos, "cid-lookup-result", DIAG_LOOKUP_HIT_NONE)
    }

    if(GetDbgIpeAclProcInfo0(V, gCidLkp_cidPairHashHit_f, &acl_info)
       || GetDbgIpeAclProcInfo0(V, gCidLkp_cidPairTcamResultValid_f , &acl_info))
    {
        if (GetDsCategoryIdPair(V, operationMode_f, &ds_cid_pair))
        {
            if (GetDsCategoryIdPair(V, u1_g2_permit_f, &ds_cid_pair))
            {
                DIAG_INFO_CHAR(pos, "cid-pair-action", "PERMIT")
            }
            else if (GetDsCategoryIdPair(V, u1_g2_deny_f, &ds_cid_pair))
            {
                DIAG_INFO_CHAR(pos, "cid-pair-action", "DENY")
            }
        }
        else
        {
            char str[64] = {0};
            sal_sprintf(str, "OverWrite-ACL-Level-%d", GetDsCategoryIdPair(V, aclLookupLevel_f, &ds_cid_pair));
            DIAG_INFO_CHAR(pos, "cid-pair-action", str)
            DIAG_INFO_UINT32(pos, "acl-lookup-type", GetDsCategoryIdPair(V, u1_g1_lookupType_f, &ds_cid_pair))

            if(!GetDsCategoryIdPair(V, u1_g1_keepAclLabel_f, &ds_cid_pair))
            {
                DIAG_INFO_UINT32(pos, "acl-label", GetDsCategoryIdPair(V, u1_g1_aclLabel_f, &ds_cid_pair))
            }
            if(!GetDsCategoryIdPair(V, u1_g1_keepAclUsePIVlan_f, &ds_cid_pair))
            {
                DIAG_INFO_UINT32(pos, "use-mapped-vlan", GetDsCategoryIdPair(V, u1_g1_aclUsePIVlan_f, &ds_cid_pair))
            }
            if (!GetDsCategoryIdPair(V, u1_g1_keepAclUseGlobalPortType_f, &ds_cid_pair))
            {
                DIAG_INFO_UINT32(pos, "use-mapped-gport", GetDsCategoryIdPair(V, u1_g1_aclUseGlobalPortType_f, &ds_cid_pair))
            }
        }
    }


    return CTC_E_NONE;
}

#if 0
enum sys_acl_key_ltid_type_e
{
    SYS_ACL_KEY_LTID_MAC          = 1,                /**< [GB.GG.D2.TM] ACL MAC key type */
    SYS_ACL_KEY_LTID_IPV4         = 2,               /**< [GB.GG.D2.TM] ACL IPv4 key type */
    SYS_ACL_KEY_LTID_MPLS         = 3,              /**< [GB.GG] ACL MPLS key type, In DT2, replaced by SYS_ACL_KEY_LTID_MAC_IPV4*/
    SYS_ACL_KEY_LTID_IPV6         = 4,               /**< [GB.GG.D2.TM] Mode 0: ACL Mac+IPv6 key type, Mode 1: ACL Ipv6 key type */
    SYS_ACL_KEY_LTID_IPV4_EXT     = 5,           /**< [D2.TM] ACL IPv4 extend key type */
    SYS_ACL_KEY_LTID_MAC_IPV4     = 6,           /**< [D2.TM] ACL Mac+IPv4 key type */
    SYS_ACL_KEY_LTID_MAC_IPV4_EXT = 7,       /**< [D2.TM] ACL Mac+IPv4 extend key type */
    SYS_ACL_KEY_LTID_IPV6_EXT     = 8,           /**< [D2.TM] ACL IPv6 extend key type */
    SYS_ACL_KEY_LTID_MAC_IPV6     = 9,           /**< [D2.TM] ACL Mac+IPv6 extend key type */
    SYS_ACL_KEY_LTID_CID          = 10,                /**< [D2.TM] ACL Category Id key type */
    SYS_ACL_KEY_LTID_INTERFACE    = 11,          /**< [D2.TM] ACL Interface key type */
    SYS_ACL_KEY_LTID_FWD          = 12,                /**< [D2.TM] ACL Forward key type */
    SYS_ACL_KEY_LTID_FWD_EXT      = 13,            /**< [D2.TM] ACL Forward key type */
    SYS_ACL_KEY_LTID_COPP         = 14,               /**< [D2.TM] ACL Copp key type */
    SYS_ACL_KEY_LTID_COPP_EXT     = 15,           /**< [D2.TM] ACL Copp extend key type */
    SYS_ACL_KEY_LTID_UDF          = 16,                /**< [TM] ACL UDF key type */
    SYS_ACL_KEY_LTID_SH           = 17,                /**< [TM] ACL UDF key type */
    SYS_ACL_KEY_LTID_MAX

};
#endif

const char* diag_map_acl_ltid[] = {
            "MAC_KEY",      "IPV4_KEY",     /*"MPLS_KEY",*/         "IPV6_KEY",
            "IPV4_EXT_KEY", "MAC_IPV4_KEY", "MAC_IPV4_EXT_KEY", "IPV6_EXT_KEY",
            "MAC_IPV6_KEY", "CID_KEY",      "INTERFACE_KEY",    "FWD_KEY",
            "FWD_EXT_KEY",  "COPP_KEY",     "COPP_EXT_KEY",     "UDF_KEY",
            "STK_HDR_KEY"};
const char* diag_acl_key_size[] = {"160", "320", "480"};

STATIC int32
_sys_at_diag_pkt_trace_get_ipe_acl_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint8  pos = CTC_DIAG_TRACE_POS_IPE;
    uint8  loop = 0;
    uint8  key_len_type = 0;
    uint8  ltid = 0;
    uint8  step1 = DbgProgramLtidTcamEngineAclInfoIgr_gAclLookup_1_lookupEn_f - DbgProgramLtidTcamEngineAclInfoIgr_gAclLookup_0_lookupEn_f;
    char ltid_lkup_rslt[12] = "";
    char acl_lkup_rslt[24] = "";
    char acl_lkup_key[12] = "";
    uint32 data_buf[CTC_B2W_SIZE(160)]={0};
    DbgIpeAclProcInfo0_m acl_proc0_info;
    DbgProgramLtidTcamEngineAclKeyInfoIgr_m ltid_key;
    DbgProgramLtidTcamEngineAclInfoIgr_m ltid_info;
    DbgProgramAclTcamEngineAclKeyInfoIgr0_m acl_key;
    DbgProgramAclTcamEngineAclInfoIgr0_m acl_info;
    DsAcl0Ingress_m dsacl0ingress;
    sal_memset(&dsacl0ingress, 0, sizeof(dsacl0ingress));

    cmd = DRV_IOR(DbgIpeAclProcInfo0_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &acl_proc0_info));

    cmd = DRV_IOR(DbgProgramLtidTcamEngineAclInfoIgr_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &ltid_info));
    cmd = DRV_IOR(DbgProgramLtidTcamEngineAclKeyInfoIgr_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &ltid_key));

    if (!GetDbgIpeAclProcInfo0(V, valid_f, &acl_proc0_info) &&
        !GetDbgProgramLtidTcamEngineAclInfoIgr(V, valid_f, &ltid_info))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
    DIAG_INFO_NONE(pos, "ACL/TCAM Processing")

    DIAG_INFO_UINT32(pos, "exception-id", GetDbgIpeAclProcInfo0(V, exceptionId_f, &acl_proc0_info))
    DIAG_INFO_CHAR(pos, "from-stk", GetDbgIpeAclProcInfo0(V, fromCflex_f, &acl_proc0_info)? DIAG_YES: DIAG_NO)
    DIAG_INFO_CHAR(pos, "mac-known", GetDbgIpeAclProcInfo0(V, macKnown_f, &acl_proc0_info)? DIAG_YES: DIAG_NO)
    DIAG_INFO_U32_HEX(pos, "log-vector", GetDbgIpeAclProcInfo0(V, tempLogVector_f, &acl_proc0_info))
    if (1 == GetDbgProgramLtidTcamEngineAclKeyInfoIgr(V, valid_f, &ltid_key))
    {
        DIAG_INFO_CHAR(pos, "acl-use-outer", GetDbgProgramLtidTcamEngineAclKeyInfoIgr(V, aclUseInnerPktInfo_f, &ltid_key)? DIAG_NO: DIAG_YES)
        GetDbgProgramLtidTcamEngineAclKeyInfoIgr(A, ltidKey_f, &ltid_key, data_buf);
        DIAG_INFO_UDF(pos, "ltid-key", data_buf)
    }

    for (loop=0; loop<DIAG_IGS_ACL_LKUP_NUM; loop++)
    {
        if (0 == GetDbgProgramLtidTcamEngineAclInfoIgr(V, gAclLookup_0_lookupEn_f + step1*loop, &ltid_info))
        {
            continue;
        }

        sal_sprintf(ltid_lkup_rslt, "ltid-hit%-2d", loop);
        if (1 == GetDbgProgramLtidTcamEngineAclInfoIgr(V, gAclLookup_0_ltidHit_f + step1*loop, &ltid_info))
        {
            DIAG_INFO_CHAR(pos, ltid_lkup_rslt, DIAG_LOOKUP_HIT)
        }
        else
        {
            DIAG_INFO_CHAR(pos, ltid_lkup_rslt, DIAG_LOOKUP_DEFAULT)
        }

        DIAG_INFO_UINT32(pos, "ltid-ad-index", GetDbgProgramLtidTcamEngineAclInfoIgr(V, gAclLookup_0_dsLtidSelectAdAddr_f + step1*loop, &ltid_info))
        cmd = DRV_IOR(DbgProgramAclTcamEngineAclInfoIgr0_t + loop, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &acl_info));
        if (!GetDbgProgramAclTcamEngineAclInfoIgr0(V, valid_f, &acl_info))
        {
            continue;
        }
        cmd = DRV_IOR(DbgProgramAclTcamEngineAclKeyInfoIgr0_t + loop, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &acl_key));
        key_len_type = GetDbgProgramAclTcamEngineAclInfoIgr0(V, keyLenType_f, &acl_info);
        sal_sprintf(acl_lkup_rslt, "TCAM%u-lookup-result", loop);
        if (GetDbgProgramAclTcamEngineAclInfoIgr0(V, hit_f, &acl_info))
        {
            DIAG_INFO_CHAR(pos, acl_lkup_rslt, DIAG_LOOKUP_HIT)
            DIAG_INFO_UINT32(pos, "key-index", GetDbgProgramAclTcamEngineAclInfoIgr0(V, index_f, &acl_info))
            DIAG_INFO_XDATA_PROF(pos,GetDbgProgramAclTcamEngineAclInfoIgr0(V, index_f, &acl_info),GetDsAcl0Ingress,DsAcl0Ingress_t + (loop*( DsAcl1Ingress_t- DsAcl0Ingress_t)),dsacl0ingress)
        }
        else if (key_len_type != 3)
        {
            DIAG_INFO_CHAR(pos, acl_lkup_rslt, DIAG_LOOKUP_HIT_NONE)
        }
        if (1 == GetDbgProgramAclTcamEngineAclKeyInfoIgr0(V, valid_f, &acl_key))
        {
            GetDbgProgramAclTcamEngineAclKeyInfoIgr0(A, key_f, &acl_key, data_buf);
            sal_sprintf(acl_lkup_key, "lkup-key%-2d", loop);
            DIAG_INFO_U32_LIST(pos, acl_lkup_key, data_buf, CTC_B2W_SIZE(160));
        }

        ltid = GetDbgProgramAclTcamEngineAclInfoIgr0(V, ltid_f, &acl_info);
        if (ltid >= 16 && ltid < 32)
        {
            DIAG_INFO_CHAR(pos, "key-type", diag_map_acl_ltid[ltid - 16])
        }
        else
        {
            DIAG_INFO_UINT32(pos, "key-ltid", ltid)
        }
        if (key_len_type != 3)
        {
            DIAG_INFO_CHAR(pos, "key-size", diag_acl_key_size[key_len_type])
        }
        DIAG_INFO_NONE(pos," ")
    }

    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_ipe_cid_pair_info(lchip, p_rslt));

    DIAG_INFO_XDATA(pos , GetDbgIpeAclProcInfo0, acl_proc0_info)

    /* Drop Process */
    _sys_at_diag_pkt_tracce_drop_map(lchip,p_rslt,
                                          GetDbgIpeAclProcInfo0(V, discard_f, &acl_proc0_info),
                                          GetDbgIpeAclProcInfo0(V, discardType_f, &acl_proc0_info));
    /* Exception Process */
    _sys_at_diag_pkt_tracce_exception_map(lchip,p_rslt,
                                               GetDbgIpeAclProcInfo0(V, exceptionEn_f, &acl_proc0_info),
                                               GetDbgIpeAclProcInfo0(V, exceptionIndex_f, &acl_proc0_info),
                                               GetDbgIpeAclProcInfo0(V, exceptionSubIndex_f, &acl_proc0_info));
    return CTC_E_NONE;
}

STATIC int32
_sys_at_diag_pkt_trace_get_ipfix_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt, uint8 dir)
{
    uint32 cmd = 0;
    uint32 value = 0;
    uint32 value_array[4] = {0};
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    DbgIpfixAccInfo_m  ipfixAccInfo;
    if(dir == 0)
    {
        pos = CTC_DIAG_TRACE_POS_IPE;
        cmd = DRV_IOR(DbgIpfixAccInfo0_t, DRV_ENTRY_FLAG);
    }
    else
    {
        pos = CTC_DIAG_TRACE_POS_EPE;
        cmd = DRV_IOR(DbgIpfixAccInfo1_t, DRV_ENTRY_FLAG);
    }
    CTC_ERROR_DUMP(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &ipfixAccInfo));
    if (!GetDbgIpfixAccInfo(V, valid_f, &ipfixAccInfo))
    {
        return CTC_E_NONE;
    }
    DIAG_INFO_NONE(pos, dir ? "Egress Ipfix Process" : "Ingress Ipfix Process");
    DIAG_INFO_CHAR(pos, "ipfix-enable", GetDbgIpfixAccInfo(V, ipfixEn_f, &ipfixAccInfo) ? "ENABLE" : "DISABLE")
    DIAG_INFO_UINT32(pos, "ipfix-configure-profile-id", GetDbgIpfixAccInfo(V, ipfixCfgProfileId_f, &ipfixAccInfo))
    DIAG_INFO_UINT32(pos, "hash-key-type", GetDbgIpfixAccInfo(V, hashKeyType_f, &ipfixAccInfo))
    DIAG_INFO_UINT32(pos, "hash-field-sele ct-id", GetDbgIpfixAccInfo(V, flowFieldSel_f, &ipfixAccInfo))

    if(GetDbgIpfixAccInfo(V, resultValid_f, &ipfixAccInfo))
    {
        value = GetDbgIpfixAccInfo(V, hashConflict_f, &ipfixAccInfo);
        DIAG_INFO_CHAR(pos, "hash-lookup-result", value ? DIAG_LOOKUP_CONFLICT : DIAG_LOOKUP_HIT)
        DIAG_INFO_UINT32(pos, "key-index", GetDbgIpfixAccInfo(V, keyIndex_f, &ipfixAccInfo))
    }

    if(GetDbgIpfixAccInfo(V, samplingEn_f, &ipfixAccInfo))
    {
        value = GetDbgIpfixAccInfo(V, isSamplingPkt_f, &ipfixAccInfo);
        DIAG_INFO_CHAR(pos, "sample-packet", value ? "TRUE" : "FALSE")
    }
    value = GetDbgIpfixAccInfo(V, isAddOperation_f, &ipfixAccInfo);
    DIAG_INFO_CHAR(pos, "operation-add", value ? "TRUE" : "FALSE")
    value = GetDbgIpfixAccInfo(V, isUpdateOperation_f, &ipfixAccInfo);
    DIAG_INFO_CHAR(pos, "operation-update", value ? "TRUE" : "FALSE")
    value = GetDbgIpfixAccInfo(V, byPassIpfixProcess_f, &ipfixAccInfo);
    DIAG_INFO_CHAR(pos, "operation-bypass", value ? "TRUE" : "FALSE")
    value = GetDbgIpfixAccInfo(V, denyIpfixInsertOperation_f, &ipfixAccInfo);
    DIAG_INFO_CHAR(pos, "operation-deny-learning", value ? "TRUE" : "FALSE")

    DIAG_INFO_UINT32(pos, "destination-info", GetDbgIpfixAccInfo(V, destinationInfo_f, &ipfixAccInfo))
    DIAG_INFO_UINT32(pos, "destination-type", GetDbgIpfixAccInfo(V, destinationType_f, &ipfixAccInfo))
    if(GetDbgIpfixAccInfo(V, ipfixXKeyEn_f, &ipfixAccInfo))
    {
        GetDbgIpfixAccInfo(A, auxData_f, &ipfixAccInfo, value_array);
        DIAG_INFO_U32_LIST(pos, "Xkey-auxdata", value_array, (sizeof(value_array)/sizeof(uint32)))
    }
    value = GetDbgIpfixAccInfo(V, latencyMonEn_f, &ipfixAccInfo);
    DIAG_INFO_CHAR(pos, "latency-monitor-en", value ? "ENABLE" : "DISENABLE")

    return CTC_E_NONE;
}

STATIC int32
_sys_at_diag_pkt_trace_get_ipe_fcoe_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    DbgIpeFcoeInfo_m fcoe_info;

    sal_memset(&fcoe_info, 0, sizeof(fcoe_info));
    cmd = DRV_IOR(DbgIpeFcoeInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &fcoe_info));
    if (!GetDbgIpeFcoeInfo(V, valid_f, &fcoe_info))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
    DIAG_INFO_NONE(pos, "FCoE")
    if (GetDbgIpeFcoeInfo(V, fcoeDaResultValid_f, &fcoe_info))
    {
        DIAG_INFO_CHAR(pos, "fcoe-da-result", "HIT")
    }
    if (GetDbgIpeFcoeInfo(V, fcoeSaResultValid_f, &fcoe_info))
    {
        DIAG_INFO_CHAR(pos, "fcoe-sa-result", "HIT")
    }

    /* Drop Process */
    _sys_at_diag_pkt_tracce_drop_map(lchip,p_rslt,
                                      GetDbgIpeFcoeInfo(V, discard_f, &fcoe_info),
                                      GetDbgIpeFcoeInfo(V, discardType_f, &fcoe_info));
    /* Exception Process */
    _sys_at_diag_pkt_tracce_exception_map(lchip,p_rslt,
                                               GetDbgIpeFcoeInfo(V, exceptionEn_f, &fcoe_info),
                                               GetDbgIpeFcoeInfo(V, exceptionIndex_f, &fcoe_info),
                                               GetDbgIpeFcoeInfo(V, exceptionSubIndex_f, &fcoe_info));
    return CTC_E_NONE;
}

STATIC int32
_sys_at_diag_pkt_trace_get_ipe_trill_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    DbgIpeTrillInfo_m trill_info;

    sal_memset(&trill_info, 0, sizeof(trill_info));
    cmd = DRV_IOR(DbgIpeTrillInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &trill_info));
    if (!GetDbgIpeTrillInfo(V, valid_f, &trill_info))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
    DIAG_INFO_NONE(pos, "TRILL")
    if (GetDbgIpeTrillInfo(V, trillResultValid_f, &trill_info))
    {
        DIAG_INFO_CHAR(pos, "trill-result", "HIT")
    }

    /* Drop Process */
    _sys_at_diag_pkt_tracce_drop_map(lchip,p_rslt,
                                          GetDbgIpeTrillInfo(V, discard_f, &trill_info),
                                          GetDbgIpeTrillInfo(V, discardType_f, &trill_info));
    /* Exception Process */
    _sys_at_diag_pkt_tracce_exception_map(lchip,p_rslt,
                                               GetDbgIpeTrillInfo(V, exceptionEn_f, &trill_info),
                                               GetDbgIpeTrillInfo(V, exceptionIndex_f, &trill_info),
                                               GetDbgIpeTrillInfo(V, exceptionSubIndex_f, &trill_info));
    return CTC_E_NONE;
}

STATIC int32
_sys_at_diag_pkt_trace_get_ipe_stmctl_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    char *str_stmctl_type[] = {"Broadcast", "Unknow-Ucast", "Know-Mcast", "Unknow-Mcast"};
    char *str_pkt_type[] = {"None",       "None",         "Ip-Ucast",  "Ip-Mcast",
                            "L2-Ucast",    "L2-Mcast",    "Broadcast", "L2",
                            "Mpls",        "Vpls",        "L3-Vpn",    "Vpws",
                            "Trill-Ucast", "Trill-Mcast", "Fcoe",      "Mpls-Other-Vpn"};
    char *str_know_type[] = {"Unknown-", "Known-"};
    char pkt_type[64]={0};
    char *sys_diag_color[] = {"None", "Red", "Yellow", "Green"};
    DbgIpeFwdStormCtlInfo_m storm_ctl_info;
    IpeStormCtl_m ipe_storm_ctl;
    uint32 stormCtlOffsetSel = 0;
    uint8 storm_ctl_type = 0;

    sal_memset(&storm_ctl_info, 0, sizeof(DbgIpeFwdStormCtlInfo_m));
    cmd = DRV_IOR(DbgIpeFwdStormCtlInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &storm_ctl_info));
    sal_memset(&ipe_storm_ctl, 0, sizeof(IpeStormCtl_m));
    cmd = DRV_IOR(IpeStormCtl_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &ipe_storm_ctl));
        /*stormctl*/
    stormCtlOffsetSel = GetDbgIpeFwdStormCtlInfo(V, offsetSel_f, &storm_ctl_info);
    storm_ctl_type = GetIpeStormCtl(V, g_0_ptrOffset_f+stormCtlOffsetSel, &ipe_storm_ctl);
    if(!(GetDbgIpeFwdStormCtlInfo(V, stormCtlEn_f, &storm_ctl_info)
       && GetDbgIpeFwdStormCtlInfo(V, valid_f, &storm_ctl_info)) || 3 < storm_ctl_type)
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_IPE;

    sal_strncat(pkt_type,str_know_type[CTC_IS_BIT_SET(stormCtlOffsetSel, 4)], sizeof(pkt_type)-1);
    sal_strncat(pkt_type,str_pkt_type[CTC_BIT_UNSET(stormCtlOffsetSel, 4)], sizeof(pkt_type)-1);

    DIAG_INFO_NONE(pos, "Storm Control")
    DIAG_INFO_CHAR(pos, "stormctl-color", sys_diag_color[GetDbgIpeFwdStormCtlInfo(V, color_f, &storm_ctl_info)])
    DIAG_INFO_CHAR(pos, "stormctl-type", STR_ARRAY(str_stmctl_type,storm_ctl_type))
    DIAG_INFO_CHAR(pos, "stormctl-pkt-type",pkt_type)

    if (GetDbgIpeFwdStormCtlInfo(V, piStormCtlDrop_f, &storm_ctl_info))
    {
        DIAG_INFO_CHAR(pos, "pi-stormctl-result", "DROP")
    }
    if (GetDbgIpeFwdStormCtlInfo(V, piStormCtlExceptionEn_f, &storm_ctl_info))
    {
        DIAG_INFO_CHAR(pos, "pi-stormctl-result", "EXCEPTION")
    }

    if (GetDbgIpeFwdStormCtlInfo(V, stormCtlDrop_f, &storm_ctl_info))
    {
        DIAG_INFO_CHAR(pos, "stormctl-result", "DROP")
    }
    if (GetDbgIpeFwdStormCtlInfo(V, stormCtlExceptionEn_f, &storm_ctl_info))
    {
        DIAG_INFO_CHAR(pos, "stormctl-result", "EXCEPTION")
    }

    if (GetDbgIpeFwdStormCtlInfo(V, stormCtlPtrValid0_f, &storm_ctl_info))
    {
        DIAG_INFO_UINT32(pos, "stormctl-length", GetDbgIpeFwdStormCtlInfo(V, stormCtlLen_f, &storm_ctl_info));
        DIAG_INFO_UINT32(pos, "stormctl-ptr-0", GetDbgIpeFwdStormCtlInfo(V, stormCtlPtr0_f, &storm_ctl_info))
    }
    if (GetDbgIpeFwdStormCtlInfo(V, stormCtlPtrValid1_f, &storm_ctl_info))
    {
        DIAG_INFO_UINT32(pos, "stormctl-length", GetDbgIpeFwdStormCtlInfo(V, stormCtlLen_f, &storm_ctl_info));
        DIAG_INFO_UINT32(pos, "stormctl-ptr-1", GetDbgIpeFwdStormCtlInfo(V, stormCtlPtr1_f, &storm_ctl_info))
    }

    return CTC_E_NONE;
}
STATIC int32
_sys_at_diag_pkt_trace_get_ipe_policer_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint32 value = 0;
    uint8 port_policerEn[2] = {0};
    uint8 vlan_policerEn[2] = {0};
    uint8 policerValid[2] = {0};
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    DbgIpeFwdPolicingInfo_m policer_info;
    char *sys_diag_color[] = {"None", "Red", "Yellow", "Green"};

    sal_memset(&policer_info, 0, sizeof(DbgIpeFwdPolicingInfo_m));
    cmd = DRV_IOR(DbgIpeFwdPolicingInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &policer_info));

    /*policer*/
    if(!GetDbgIpeFwdPolicingInfo(V, valid_f, &policer_info))
    {
        return CTC_E_NONE;
    }
    port_policerEn[0] = GetDbgIpeFwdPolicingInfo(V, portPolicer0En_f, &policer_info);
    port_policerEn[1] = GetDbgIpeFwdPolicingInfo(V, portPolicer1En_f, &policer_info);
    vlan_policerEn[0] = GetDbgIpeFwdPolicingInfo(V, vlanPolicer0En_f, &policer_info);
    vlan_policerEn[1] = GetDbgIpeFwdPolicingInfo(V, vlanPolicer1En_f, &policer_info);
    policerValid[0] = GetDbgIpeFwdPolicingInfo(V, policerValid0_f, &policer_info);
    policerValid[1] = GetDbgIpeFwdPolicingInfo(V, policerValid1_f, &policer_info);

    if (!(policerValid[0] || policerValid[1]))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
    DIAG_INFO_NONE(pos, "Policing")
    DIAG_INFO_CHAR(pos, "policer-color", sys_diag_color[GetDbgIpeFwdPolicingInfo(V, policerColor_f, &policer_info)])
    DIAG_INFO_UINT32(pos, "policer-length", GetDbgIpeFwdPolicingInfo(V, policerLength_f, &policer_info))
    DIAG_INFO_UINT32(pos, "policer-l3-length", GetDbgIpeFwdPolicingInfo(V, policerLayer3Length_f, &policer_info))
    DIAG_INFO_UINT32(pos, "muxLengthType", GetDbgIpeFwdPolicingInfo(V, muxLengthType_f, &policer_info))
    value = GetDbgIpeFwdPolicingInfo(V, policyProfId_f, &policer_info);
    if (value)
    {
        DIAG_INFO_UINT32(pos, "policer-profile-id", value)
    }

    if (policerValid[0])
    {
        value = GetDbgIpeFwdPolicingInfo(V, policerPhbEn0_f, &policer_info);
        DIAG_INFO_CHAR(pos, "policer-0-phb", value ? "ENABLE" : "DISABLE")
        if (port_policerEn[0])
        {
            DIAG_INFO_CHAR(pos, "policer-0-port", "ENABLE")
        }
        if (vlan_policerEn[0])
        {
            DIAG_INFO_CHAR(pos, "policer-0-vlan",  "ENABLE")
        }
        DIAG_INFO_UINT32(pos, "policer-0-ptr", GetDbgIpeFwdPolicingInfo(V, policerPtr0_f, &policer_info))
        DIAG_INFO_UINT32(pos, "policer-0-stats-ptr", GetDbgIpeFwdPolicingInfo(V, policerStatsPtr0_f, &policer_info))
    }
    if (policerValid[1])
    {
        DIAG_INFO_CHAR(pos, "policer-1-split", "DISABLE")
        value = GetDbgIpeFwdPolicingInfo(V, policerPhbEn1_f, &policer_info);
        DIAG_INFO_CHAR(pos, "policer-1-phb", value ? "ENABLE" : "DISABLE")
        if (port_policerEn[1])
        {
            DIAG_INFO_CHAR(pos, "policer-1-port", "ENABLE")
        }
        if (vlan_policerEn[1])
        {
            DIAG_INFO_CHAR(pos, "policer-1-vlan", "ENABLE")
        }
        DIAG_INFO_UINT32(pos, "policer-1-ptr", GetDbgIpeFwdPolicingInfo(V, policerPtr1_f, &policer_info))
        DIAG_INFO_UINT32(pos, "policer-1-stats-ptr", GetDbgIpeFwdPolicingInfo(V, policerStatsPtr1_f, &policer_info))
    }
    return CTC_E_NONE;
}

STATIC int32
_sys_at_diag_pkt_trace_get_ipe_copp_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    DbgIpeFwdCoppInfo_m copp_info;
    char *sys_diag_color[] = {"None", "Red", "Yellow", "Green"};

    sal_memset(&copp_info, 0, sizeof(DbgIpeFwdCoppInfo_m));
    cmd = DRV_IOR(DbgIpeFwdCoPPInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &copp_info));

    /*copp*/
    if (!(GetDbgIpeFwdCoppInfo(V, valid_f,&copp_info)
        && GetDbgIpeFwdCoppInfo(V, coppValid_f, &copp_info)))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
    DIAG_INFO_NONE(pos, "CoPP")
    DIAG_INFO_CHAR(pos, "copp-color", sys_diag_color[GetDbgIpeFwdCoppInfo(V, color_f, &copp_info)])
    DIAG_INFO_UINT32(pos, "copp-length", GetDbgIpeFwdCoppInfo(V, coppLen_f, &copp_info))
    DIAG_INFO_UINT32(pos, "copp-ptr", GetDbgIpeFwdCoppInfo(V, coppPtr_f, &copp_info))
    DIAG_INFO_U32_HEX(pos, "copp-stats-ptr", GetDbgIpeFwdCoppInfo(V, coppStatsPtr_f, &copp_info))
    if(GetDbgIpeFwdCoppInfo(V, coppDrop_f, &copp_info))
    {
        DIAG_INFO_CHAR(pos, "copp-result", "DROP")
    }
    return CTC_E_NONE;
}

STATIC int32
_sys_at_diag_pkt_trace_get_ipe_dest_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
 {
    uint32 cmd = 0;
    uint32 value = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    uint8 pos_tmp = CTC_DIAG_TRACE_POS_IPE;
    uint32 rx_oam_type = 0;
    uint32 hdr_data[DIAG_PKT_HDR_ALL_LEN/4] = {0};
    uint32 hdr_data_temp[CTC_DIAG_PACKET_HEAR_LEN/4] = {0};
    DbgIpeEcmpProcInfo_m ecmp_info;
    DbgIpeFwdProcessInfo_m fwd_info;
    DbgIpeAclProcInfo0_m   acl_info;
    DbgIpeFwdInputHeaderInfo_m ipe_hdr;
    DbgEcmpDlbEngineInfo_m dlb_info;
    DbgLagEngineInfo_m lag_info;

    cmd = DRV_IOR(DbgIpeFwdInputHeaderInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &ipe_hdr));
    cmd = DRV_IOR(DbgIpeEcmpProcInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &ecmp_info));
    cmd = DRV_IOR(DbgIpeFwdProcessInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &fwd_info));
    cmd = DRV_IOR(DbgIpeAclProcInfo0_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &acl_info));
    cmd = DRV_IOR(DbgIpeOamInfo_t, DbgIpeOamInfo_tempRxOamType_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &rx_oam_type));
    cmd = DRV_IOR(DbgEcmpDlbEngineInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &dlb_info));
    cmd = DRV_IOR(DbgLagEngineInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &lag_info));

    if (!GetDbgIpeFwdProcessInfo(V, valid_f,  &fwd_info))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
    DIAG_INFO_NONE(pos, "Destination Processing")

    GetDbgIpeFwdInputHeaderInfo(A, data_f, &ipe_hdr, hdr_data);
    if (sal_memcmp(&hdr_data[(DIAG_PKT_XHDR_LEN)/4], hdr_data_temp, (CTC_DIAG_PACKET_HEAR_LEN/4) * sizeof(uint32)))
    {
        DIAG_INFO_PKT_HDR(pos, "packet-header", &hdr_data[(DIAG_PKT_XHDR_LEN)/4], CTC_DIAG_TRACE_STR_LEN/4)
    }

    value = GetDbgIpeEcmpProcInfo(V, ecmpGroupId_f, &ecmp_info);
    if (GetDbgIpeEcmpProcInfo(V, ecmpEn_f, &ecmp_info)
        && GetDbgIpeEcmpProcInfo(V, valid_f, &ecmp_info)
        && value)
    {
        DIAG_INFO_CHAR(pos, "dest-type", "ECMP")
        DIAG_INFO_UINT32(pos, "ecmp-group", value)
        DIAG_INFO_CHAR(pos, "ecmp-stage1", GetDbgIpeEcmpProcInfo(V, ecmpStage1En_f, &ecmp_info)? DIAG_ENABLE: DIAG_DISABLE)
        DIAG_INFO_CHAR(pos, "ecmp-stage2", GetDbgIpeEcmpProcInfo(V, ecmpStage2En_f, &ecmp_info)? DIAG_ENABLE: DIAG_DISABLE)
        DIAG_INFO_CHAR(pos, "ecmp-lsh", GetDbgIpeEcmpProcInfo(V, ecmpLinkSelfHealingEn_f, &ecmp_info)? DIAG_ENABLE: DIAG_DISABLE)
        DIAG_INFO_UINT32(pos, "hash-value0", GetDbgIpeEcmpProcInfo(V, hashValue0_f, &ecmp_info))
        DIAG_INFO_UINT32(pos, "hash-value1", GetDbgIpeEcmpProcInfo(V, hashValue1_f, &ecmp_info))

        if (GetDbgIpeEcmpProcInfo(V, antFlowPathValid_f, &ecmp_info))
        {
            DIAG_INFO_CHAR(pos, "antFlowEn", DIAG_ENABLE)
            DIAG_INFO_UINT32(pos, "active", GetDbgIpeEcmpProcInfo(V, antFlowActive_f, &ecmp_info))
            DIAG_INFO_UINT32(pos, "link-state", GetDbgIpeEcmpProcInfo(V, antFlowLinkState_f, &ecmp_info))
            DIAG_INFO_UINT32(pos, "path-valid", 1)
            DIAG_INFO_U32_HEX(pos, "index", GetDbgIpeEcmpProcInfo(V, antFlowIndex_f, &ecmp_info))
            DIAG_INFO_U32_HEX(pos, "record-info", GetDbgIpeEcmpProcInfo(V, antFlowRecordInfo_f, &ecmp_info))
        }
        if (GetDbgEcmpDlbEngineInfo(V, valid_f, &dlb_info))
        {
            if (GetDbgEcmpDlbEngineInfo(V, isUpdateOperation_f, &dlb_info))
            {
                DIAG_INFO_CHAR(pos, "flow-state", DIAG_LOOKUP_HIT)
                if (GetDbgEcmpDlbEngineInfo(V, rebalance_f, &dlb_info))
                {
                    DIAG_INFO_CHAR(pos, "rebalance", DIAG_YES)
                    DIAG_INFO_CHAR(pos, "force-rebalance", GetDbgEcmpDlbEngineInfo(V, memberSelChangeForceReb_f, &dlb_info)? DIAG_YES: DIAG_NO)
                    DIAG_INFO_CHAR(pos, "rebalance-ready", GetDbgEcmpDlbEngineInfo(V, rebalanceReady_f, &dlb_info)? DIAG_YES: DIAG_NO)
                    DIAG_INFO_UINT32(pos, "rebalance-cnt", GetDbgEcmpDlbEngineInfo(V, rebalanceCount_f, &dlb_info))
                }
                else
                {
                    DIAG_INFO_CHAR(pos, "rebalance", DIAG_NO)
                    DIAG_INFO_CHAR(pos, "disable-rebalance", GetDbgEcmpDlbEngineInfo(V, disableRebalance_f, &dlb_info)? DIAG_YES: DIAG_NO)
                    DIAG_INFO_CHAR(pos, "rebalance-ready", GetDbgEcmpDlbEngineInfo(V, rebalanceReady_f, &dlb_info)? DIAG_YES: DIAG_NO)
                    DIAG_INFO_CHAR(pos, "all-link-down", GetDbgEcmpDlbEngineInfo(V, allSelectLinkDown_f, &dlb_info)? DIAG_YES: DIAG_NO)
                }
            }
            else if (GetDbgEcmpDlbEngineInfo(V, isConflictOperation_f, &dlb_info))
            {
                DIAG_INFO_CHAR(pos, "flow-state", DIAG_LOOKUP_CONFLICT)
            }
            else
            {
                DIAG_INFO_CHAR(pos, "flow-state", DIAG_LOOKUP_HIT_NONE)
            }
        }
        p_rslt->ecmp_group = value;
        p_rslt->flags |= CTC_DIAG_TRACE_RSTL_FLAG_ECMP_GROUP;
    }

    if (GetDbgIpeAclProcInfo0(V, apsBridgeValid0_f, &acl_info))
    {
        DIAG_INFO_CHAR(pos, "dest-type", "APS")
        DIAG_INFO_UINT32(pos, "aps-group-1st-level", GetDbgIpeAclProcInfo0(V, apsBridgeIndex0_f, &acl_info))
        if (GetDbgIpeAclProcInfo0(V, apsBridgeValid1_f,  &acl_info))
        {
            DIAG_INFO_UINT32(pos, "aps-group-2nd-level", GetDbgIpeAclProcInfo0(V, apsBridgeIndex1_f, &acl_info))
        }
    }
    else
    {
        if (GetDbgIpeAclProcInfo0(V, apsSelectValid0_f,  &acl_info))
        {
            DIAG_INFO_UINT32(pos, "aps-group-select-0", GetDbgIpeAclProcInfo0(V, apsSelectGroupId0_f, &acl_info))
        }
        if (GetDbgIpeAclProcInfo0(V, apsSelectValid1_f,  &acl_info))
        {
            DIAG_INFO_UINT32(pos, "aps-group-select-1", GetDbgIpeAclProcInfo0(V, apsSelectGroupId1_f, &acl_info))
        }
    }

    if (rx_oam_type)
    {
        DIAG_INFO_CHAR(pos, "dest-type", "OAM")
        p_rslt->dest_type = CTC_DIAG_DEST_OAM;
        CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_oam_rx_info(lchip, p_rslt));
    }
    else
    {
        uint32 fwd_destMap = GetDbgIpeFwdProcessInfo(V, destMap_f,  &fwd_info);
        uint8  int_op_type = GetDbgIpeFwdProcessInfo(V, intOpType_f,  &fwd_info);
        uint8  acl_dscp_valid = GetDbgIpeFwdProcessInfo(V, aclDscpValid_f,  &fwd_info);
        uint8  src_dscp_valid = GetDbgIpeFwdProcessInfo(V, srcDscpValid_f,  &fwd_info);
        char* const int_type_desc[] = {"", "SOURCE", "TRANSIT", "SINK"};

        DIAG_INFO_CHAR(pos, "bypass-ipe", GetDbgIpeFwdProcessInfo(V, bypassIpe_f,  &fwd_info) ? "Yes" : "No")
        if (acl_dscp_valid && src_dscp_valid)
        {
            DIAG_INFO_CHAR(pos, "dscp-valid", "from acl")
        }
        else if (src_dscp_valid)
        {
            DIAG_INFO_CHAR(pos, "dscp-valid", "from src")
        }
        /*INT*/
        if (0 != int_op_type)
        {
            DIAG_INFO_CHAR(pos, "int-op-type", int_type_desc[int_op_type])
            DIAG_INFO_U32_HEX(pos, "int-op-ptr", GetDbgIpeFwdProcessInfo(V, intOpPtr_f,  &fwd_info))
            if (GetDbgIpeFwdProcessInfo(V, intIgrLog_f,  &fwd_info))
            {
                DIAG_INFO_UINT32(pos, "int-log-block", GetDbgIpeFwdProcessInfo(V, intIgrLogBlock_f,  &fwd_info))
                DIAG_INFO_UINT32(pos, "int-log-id", GetDbgIpeFwdProcessInfo(V, intIgrLogId_f,  &fwd_info))
            }
        }

        if (0x3FFFF == GetDbgIpeFwdProcessInfo(V, nextHopPtr_f,  &fwd_info))
        {
            DIAG_INFO_CHAR(pos, "dest-type", "DROP")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        else if (CTC_IS_BIT_SET(fwd_destMap, 18))/* Mcast */
        {
            DIAG_INFO_CHAR(pos, "dest-type", "Mcast Group")
            DIAG_INFO_UINT32(pos, "mcast-group", fwd_destMap&0xFFFF)
            p_rslt->mc_group = fwd_destMap&0xFFFF;
            p_rslt->flags |= CTC_DIAG_TRACE_RSTL_FLAG_MC_GROUP;
        }
        else
        {
            uint32 dest_chip = (fwd_destMap >> 9)&0x7F;
            if (CTC_IS_BIT_SET(fwd_destMap, 16))/* fwd to cpu */
            {
                DIAG_INFO_CHAR(pos, "dest-type", "CPU")
                p_rslt->port =  CTC_GPORT_RCPU(dest_chip);
                p_rslt->flags |= CTC_DIAG_TRACE_RSTL_FLAG_PORT;
                p_rslt->dest_type = CTC_DIAG_DEST_CPU;
            }
            else
            {
                if (GetDbgLagEngineInfo(V, valid_f, &lag_info)
                 &&(GetDbgLagEngineInfo(V, portLagEnable_f, &lag_info)
                  ||GetDbgLagEngineInfo(V, chanLagEnable_f, &lag_info)
                  ||GetDbgLagEngineInfo(V, sgmacLagEnable_f, &lag_info))
                )
                {
                    p_rslt->dest_type = CTC_DIAG_DEST_NETWORK;
                    p_rslt->tid =  fwd_destMap&CTC_LINKAGGID_MASK;
                    p_rslt->flags |= CTC_DIAG_TRACE_RSTL_FLAG_TID;
                    DIAG_INFO_CHAR(pos, "dest-type", "Linkagg Port")
                    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_lag_info(lchip, &lag_info, p_rslt));
                }
                else
                {
                    value = SYS_MAP_DRV_LPORT_TO_CTC_GPORT(dest_chip, fwd_destMap&0x1FF);
                    p_rslt->port =  value;
                    p_rslt->flags |= CTC_DIAG_TRACE_RSTL_FLAG_PORT;
                    p_rslt->dest_type = CTC_DIAG_DEST_NETWORK;
                    DIAG_INFO_CHAR(pos, "dest-type", "Network Port")
                    DIAG_INFO_U32_HEX(pos, "network-port", value)
                }
/*
                cmd = DRV_IOR(EpeHdrAdjustCtl_t, EpeHdrAdjustCtl_dsNextHopInternalBase_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
*/
                DIAG_INFO_CHAR(pos, "nexthop-lookup-result", DIAG_LOOKUP_HIT)
                DIAG_INFO_U32_HEX(pos,"nexthop-ptr", GetDbgIpeFwdProcessInfo(V, nextHopPtr_f,  &fwd_info))
                /*
                if (((GetDbgIpeFwdProcessInfo(V, nextHopPtr_f,  &fwd_info) >> 4)&0x3FFF) != value)
                {
                    DIAG_INFO_CHAR(pos, "table-name", GetDbgIpeFwdProcessInfo(V, nextHopExt_f,  &fwd_info) ? "DsNextHop8W" : "DsNextHop4W")

                }
                else
                {
                    DIAG_INFO_CHAR(pos, "table-name", "EpeNextHopInternal")
                    DIAG_INFO_UINT32(pos,"table-index", (GetDbgIpeFwdProcessInfo(V, nextHopPtr_f,  &fwd_info)&0xF) >> 1)
                }
                */
            }
        }
    }

    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_ipfix_info(lchip, p_rslt, 0));

	pos_tmp = p_rslt->position;
	p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
    /* Drop Process */
    _sys_at_diag_pkt_tracce_drop_map(lchip,p_rslt,
                                          GetDbgIpeFwdProcessInfo(V, discard_f, &fwd_info),
                                          GetDbgIpeFwdProcessInfo(V, discardType_f,  &fwd_info));
    /* Exception Process */
    _sys_at_diag_pkt_tracce_exception_map(lchip,p_rslt,
                                               GetDbgIpeFwdProcessInfo(V, exceptionEn_f, &fwd_info),
                                               GetDbgIpeFwdProcessInfo(V, exceptionIndex_f, &fwd_info),
                                               GetDbgIpeFwdProcessInfo(V, exceptionSubIndex_f, &fwd_info));
	p_rslt->position = pos_tmp;
     return CTC_E_NONE;
}

STATIC int32
_sys_at_diag_pkt_trace_get_epe_scl_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint32 key_data[DIAF_EGS_SCL_KEY_SIZE] = {0};
    uint8  pos = CTC_DIAG_TRACE_POS_EPE;
    uint8  loop = 0;
    uint8  hash_hit = 0;
    uint8  dft_hit = 0;
    uint8  lkup_en[2] = {0};
    uint8  hash_type[2] = {0};
    uint8  is_xkey = 0;
    const char* key_name[] ={
        "DISABLE",          "DOUBLEVLANPORT",
        "SVLANPORT",        "CVLANPORT",
        "SVLANCOSPORT",     "CVLANCOSPORT",
        "PORTVLANCROSS",    "PORTCROSS",
        "PORT",             "SVLANPORTMAC",
        "FIDDVP",           "FIDDVPGROUP",
        "FID",              "METADATADVPGROUP",
        "I2ECIDDVPGROUP",   "METADATADVP"
    };
    DbgEgrSclHash0_m egr_scl_info[2];
    DbgEpeNextHopInfo_m next_hop_info;

    cmd = DRV_IOR(DbgEgrSclHash0_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &egr_scl_info[0]));
    cmd = DRV_IOR(DbgEgrSclHash1_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &egr_scl_info[1]));
    cmd = DRV_IOR(DbgEpeNextHopInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &next_hop_info));

    if (!GetDbgEpeNextHopInfo(V, valid_f, &next_hop_info))
    {
        return CTC_E_NONE;
    }
    if (!GetDbgEgrSclHash0(V, valid_f, &egr_scl_info[0]) &&
        !GetDbgEgrSclHash1(V, valid_f, &egr_scl_info[1]))
    {
        return CTC_E_NONE;
    }

    lkup_en[0] = GetDbgEpeNextHopInfo(V, lookup0Valid_f, &next_hop_info);
    lkup_en[1] = GetDbgEpeNextHopInfo(V, lookup1Valid_f, &next_hop_info);
    hash_type[0] = GetDbgEpeNextHopInfo(V, vlanHash0Type_f, &next_hop_info);
    hash_type[1] = GetDbgEpeNextHopInfo(V, vlanHash1Type_f, &next_hop_info);
    p_rslt->position = CTC_DIAG_TRACE_POS_EPE;
    DIAG_INFO_NONE(pos, "SCL Process")
    for (loop=0; loop<2; loop++)
    {
        hash_hit = GetDbgEgrSclHash0(V, resultValid_f, &egr_scl_info[loop]);
        dft_hit = GetDbgEgrSclHash0(V, defaultEntryValid_f, &egr_scl_info[loop]);
        is_xkey = GetDbgEgrSclHash0(V, xKeyValid_f, &egr_scl_info[loop]);
        if (lkup_en[loop] && hash_hit && !dft_hit)
        {
            DIAG_INFO_CHAR(pos, loop? "hash-1-lookup-result": "hash-0-lookup-result", DIAG_LOOKUP_HIT)
            DIAG_INFO_CHAR(pos, "flex-key", is_xkey ? DIAG_LOOKUP_HIT : DIAG_LOOKUP_HIT_NONE)
            DIAG_INFO_CHAR(pos, "key-name", key_name[hash_type[loop]])
            DIAG_INFO_UINT32(pos, "key-index", GetDbgEgrSclHash0(V, keyIndex_f, &egr_scl_info[loop]))
        }
        else if (lkup_en[loop])
        {
            DIAG_INFO_CHAR(pos, loop? "hash-1-lookup-result": "hash-0-lookup-result", hash_hit? DIAG_LOOKUP_DEFAULT: DIAG_LOOKUP_HIT_NONE)
            DIAG_INFO_CHAR(pos, "key-name", key_name[hash_type[loop]])
            DIAG_INFO_U32_HEX(pos, "key-index", GetDbgEgrSclHash0(V, keyIndex_f, &egr_scl_info[loop]))
            GetDbgEgrSclHash0(A, lookupKey_f, &egr_scl_info[loop], key_data);
            DIAG_INFO_U32_LIST(pos, "key-data", key_data, DIAF_EGS_SCL_KEY_SIZE)
        }
    }
    return CTC_E_NONE;
}


STATIC int32
_sys_at_diag_pkt_trace_get_epe_hdj_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint32 value = 0;
    uint32 nhp_nhpIs8w = 0;
    uint32 dsNextHopInternalBase = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_EPE;
    char* vlanTagAction[] = {"None", "Add", "Remove", "Replace"};
    char* str_opType[] = {"NORMAL", "LTMX", "E2ILOOP", "DMTX", "C2C", "PTP", "NAT", "OAM"};
    char *pp_info[] = {"EPE:PP-ID 0","EPE:PP-ID 1","EPE:PP-ID 2","EPE:PP-ID 3","EPE:PP-ID 4","EPE:PP-ID 5","EPE:PP-ID 6","EPE:PP-ID 7"};
    uint8 pp_id = lchip - SYS_PP_BASE(lchip);
    DbgEpeHdrAdjInfo_m hdr_info;
    DbgEpeHdrAdjInfo0_m hdr_info0;
    DbgEpeHdrAdjInfo2_m hdr_info2;

    cmd = DRV_IOR(DbgEpeHdrAdjInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &hdr_info));
    cmd = DRV_IOR(DbgEpeHdrAdjInfo0_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &hdr_info0));
    cmd = DRV_IOR(EpeHdrAdjustCtl_t, EpeHdrAdjustCtl_dsNextHopInternalBase_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &dsNextHopInternalBase));
    cmd = DRV_IOR(DbgEpeNextHopInfo_t, DbgEpeNextHopInfo_nhpIs8w_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &nhp_nhpIs8w));
    cmd = DRV_IOR(DbgEpeHdrAdjInfo2_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &hdr_info2));

    if (!GetDbgEpeHdrAdjInfo(V, valid_f, &hdr_info))
    {
        return CTC_E_NONE;
    }

    DIAG_INFO_NONE(pos, "------------------------------------------------");
    DIAG_INFO_NONE(pos, STR_ARRAY(pp_info,pp_id));
    DIAG_INFO_NONE(pos, "------------------------------------------------");

    p_rslt->position = CTC_DIAG_TRACE_POS_EPE;
    DIAG_INFO_NONE(pos, "EPE Header Adjust")

    value = GetDbgEpeHdrAdjInfo(V, channelId_f, &hdr_info);
    DIAG_INFO_UINT32(pos, "channel-id", value)
    if (!CTC_FLAG_ISSET(p_rslt->flags, CTC_DIAG_TRACE_RSTL_FLAG_MC_GROUP))
    {
        p_rslt->channel = value;
        p_rslt->flags |= CTC_DIAG_TRACE_RSTL_FLAG_CHANNLE;
    }
    if (value == MCHIP_CAP(SYS_CAP_CHANID_ILOOP))
    {
        p_rslt->loop_flags |= CTC_DIAG_LOOP_FLAG_ILOOP;
    }
    if (value == MCHIP_CAP(SYS_CAP_CHANID_ELOOP))
    {
        p_rslt->loop_flags |= CTC_DIAG_LOOP_FLAG_ELOOP;
    }

    DIAG_INFO_CHAR(pos, "dest-select", GetDbgEpeHdrAdjInfo(V, destSelect_f, &hdr_info)? "To-CPU": "Normal")

    if (GetDbgEpeHdrAdjInfo(V, bypassMacsecProc_f, &hdr_info))
    {
        DIAG_INFO_CHAR(pos, "cancel-dot1ae", DIAG_YES);
    }
    DIAG_INFO_UINT32(pos, "local-phy-port", GetDbgEpeHdrAdjInfo(V, localPhyPort_f, &hdr_info))
    if ((!GetDbgEpeHdrAdjInfo(V, bypassAll_f, &hdr_info) && !GetDbgEpeHdrAdjInfo(V, bypassEpe_f, &hdr_info)) || (0x3FFFF != GetDbgEpeHdrAdjInfo(V, nextHopPtr_f, &hdr_info)))
    {
        value = GetDbgEpeHdrAdjInfo(V, nextHopPtr_f, &hdr_info);
        DIAG_INFO_U32_HEX(pos, "nexthop-ptr", value)
        if ((value >> 4) != dsNextHopInternalBase)
        {
            DIAG_INFO_CHAR(pos, "nexthop-table-name", nhp_nhpIs8w? "DsNextHop8W" : "DsNextHop4W")
            DIAG_INFO_UINT32(pos, "nexthop-table-index", value)
        }
        else
        {
            DIAG_INFO_CHAR(pos, "nexthop-table-name",  "EpeNextHopInternal")
            DIAG_INFO_UINT32(pos, "nexthop-table-index", (value & 0xF) >> 1)
        }
    }
    DIAG_INFO_UINT32(pos, "mux-length-type", GetDbgEpeHdrAdjInfo(V, muxLengthType_f, &hdr_info))
    value = GetDbgEpeHdrAdjInfo(V, packetOffset_f, &hdr_info);
    if (value)
    {
        DIAG_INFO_UINT32(pos, "strip-packet(bytes)", value)
    }
    DIAG_INFO_UINT32(pos, "packet-length-adjust", GetDbgEpeHdrAdjInfo(V, packetLengthAdjust_f, &hdr_info))
    DIAG_INFO_UINT32(pos, "packet-length-adjust-type", GetDbgEpeHdrAdjInfo(V, packetLengthAdjustType_f, &hdr_info))
    DIAG_INFO_CHAR(pos, "operation-type",STR_ARRAY(str_opType,GetDbgEpeHdrAdjInfo(V, operationType_f, &hdr_info)))
    if (GetDbgEpeHdrAdjInfo(V, svlanTagOperationValid_f, &hdr_info))
    {
        DIAG_INFO_CHAR(pos, "svlan-action", STR_ARRAY(vlanTagAction,GetDbgEpeHdrAdjInfo(V, sTagAction_f, &hdr_info)))
    }
    if (GetDbgEpeHdrAdjInfo(V, cvlanTagOperationValid_f, &hdr_info))
    {
        DIAG_INFO_CHAR(pos, "cvlan-action", STR_ARRAY(vlanTagAction,GetDbgEpeHdrAdjInfo(V, cTagAction_f, &hdr_info)))
    }
    if (GetDbgEpeHdrAdjInfo(V, isSendtoCpuEn_f, &hdr_info))
    {
        DIAG_INFO_CHAR(pos, "send-to-cpu", "TRUE")
    }
    if (GetDbgEpeHdrAdjInfo(V, fromFabric_f, &hdr_info))
    {
        DIAG_INFO_CHAR(pos, "packet-from-fabric", "TRUE")
    }
    if (GetDbgEpeHdrAdjInfo(V, pktWithCidHeader_f, &hdr_info))
    {
        DIAG_INFO_CHAR(pos, "packet-with-cid-header", "TRUE")
    }
    if (GetDbgEpeHdrAdjInfo(V, bypassAll_f, &hdr_info))
    {
        DIAG_INFO_CHAR(pos, "egress-edit-bypass-all", "TRUE")
    }
    if (GetDbgEpeHdrAdjInfo(V, ingressEditNexthopBypassAll_f, &hdr_info))
    {
        DIAG_INFO_CHAR(pos, "ingress-edit-bypass-all", "TRUE")
    }
    if (GetDbgEpeHdrAdjInfo(V, bypassIpe_f, &hdr_info))
    {
        DIAG_INFO_CHAR(pos, "bypass-ipe", DIAG_YES)
    }
    if (GetDbgEpeHdrAdjInfo(V, bypassEpe_f, &hdr_info))
    {
        DIAG_INFO_CHAR(pos, "bypass-epe", DIAG_YES)
    }
    if (GetDbgEpeHdrAdjInfo2(V, valid_f, &hdr_info2))
    {
        value = GetDbgEpeHdrAdjInfo2(V, localNextHopPtr_f, &hdr_info2);
        DIAG_INFO_U32_HEX(pos, "localNextHop-ptr", value)
    }



    /* Drop Process */
    _sys_at_diag_pkt_tracce_drop_map(lchip,p_rslt,
                                          GetDbgEpeHdrAdjInfo(V, discard_f, &hdr_info),
                                          GetDbgEpeHdrAdjInfo(V, discardType_f,  &hdr_info));
    return CTC_E_NONE;
}

STATIC int32
_sys_at_diag_pkt_trace_get_epe_acl_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint32 temp = 0;
    uint8 idx = 0;
    uint8 ltid = 0;
    uint8 key_len_type = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_EPE;
    uint32 buffer[CTC_B2W_SIZE(160)]={0};
    char  acl_lkup_result[24] = "";
    char  ltid_lkup_result[12] = "";
    DbgProgramAclTcamEngineAclInfoEgr0_m eacl_info;
    DbgProgramAclTcamEngineAclKeyInfoEgr0_m eacl_key_info;
    DbgProgramLtidTcamEngineAclInfoEgr_m eacl_ltid_info;
    DbgProgramLtidTcamEngineAclKeyInfoEgr_m eacl_ltid_key_info;
    DbgEpeAclInfo_m epe_acl_proc_info;
    DsAcl0Egress_m  dsacl0egress;

    sal_memset(&dsacl0egress, 0, sizeof(dsacl0egress));
    cmd = DRV_IOR(DbgEpeAclInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &epe_acl_proc_info));
    cmd = DRV_IOR(DbgProgramLtidTcamEngineAclInfoEgr_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &eacl_ltid_info));

    if (!GetDbgEpeAclInfo(V, valid_f, &epe_acl_proc_info) ||
        !GetDbgProgramLtidTcamEngineAclInfoEgr(V, valid_f, &eacl_ltid_info))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_EPE;
    DIAG_INFO_NONE(pos, "Egress ACL/TCAM Processing")

    cmd = DRV_IOR(DbgProgramLtidTcamEngineAclKeyInfoEgr_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &eacl_ltid_key_info));
    if (GetDbgProgramLtidTcamEngineAclKeyInfoEgr(V, valid_f, &eacl_ltid_key_info))
    {
        DIAG_INFO_CHAR(pos, "acl-use-outer", GetDbgProgramLtidTcamEngineAclKeyInfoEgr(V, aclUseInnerPktInfo_f, &eacl_ltid_key_info)? DIAG_NO: DIAG_YES)
        GetDbgProgramLtidTcamEngineAclKeyInfoEgr(A, ltidKey_f, &eacl_ltid_key_info, buffer);
        DIAG_INFO_U32_LIST(pos, "ltid-Key", buffer, CTC_B2W_SIZE(160))
    }
    for (idx = 0; idx < DIAG_EGS_ACL_LKUP_NUM ; idx++)
    {
        if (!GetDbgProgramLtidTcamEngineAclInfoEgr(V, gAclLookup_0_lookupEn_f+idx, &eacl_ltid_info))
        {
            continue;
        }
        sal_sprintf(ltid_lkup_result, "ltid-hit%u", idx);
        if (GetDbgProgramLtidTcamEngineAclInfoEgr(V, gAclLookup_0_ltidHit_f+idx, &eacl_ltid_info))
        {
            DIAG_INFO_CHAR(pos, ltid_lkup_result, DIAG_LOOKUP_HIT)
        }
        else
        {
            DIAG_INFO_CHAR(pos, ltid_lkup_result, DIAG_LOOKUP_DEFAULT)
        }

        DIAG_INFO_UINT32(pos, "ltid-ad-index", GetDbgProgramLtidTcamEngineAclInfoEgr(V, gAclLookup_0_dsLtidSelectAdAddr_f+idx, &eacl_ltid_info))
        cmd = DRV_IOR(DbgProgramAclTcamEngineAclInfoEgr0_t+idx, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &eacl_info));
        if (!GetDbgProgramAclTcamEngineAclInfoEgr(V, valid_f, &eacl_info))
        {
            continue;
        }
        cmd = DRV_IOR(DbgProgramAclTcamEngineAclKeyInfoEgr0_t+idx, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &eacl_key_info));
        sal_sprintf(acl_lkup_result, "TCAM%u-lookup-result", idx);
        key_len_type = GetDbgProgramAclTcamEngineAclInfoEgr(V, keyLenType_f, &eacl_info);
        if (GetDbgProgramAclTcamEngineAclInfoEgr(V, hit_f, &eacl_info))
        {
            DIAG_INFO_CHAR(pos, acl_lkup_result, DIAG_LOOKUP_HIT)
            DIAG_INFO_U32_HEX(pos, "key-index", GetDbgProgramAclTcamEngineAclInfoEgr(V, index_f, &eacl_info))
            DIAG_INFO_XDATA_PROF(pos,GetDbgProgramAclTcamEngineAclInfoEgr(V, index_f, &eacl_info),GetDsAcl0Egress,DsAcl0Egress_t + (idx*(DsAcl1Egress_t-DsAcl0Egress_t)),dsacl0egress)
        }
        else if (key_len_type != 3)
        {
            DIAG_INFO_CHAR(pos, acl_lkup_result, DIAG_LOOKUP_HIT_NONE)
        }
        if (GetDbgProgramAclTcamEngineAclKeyInfoEgr(V, valid_f, &eacl_key_info))
        {
            GetDbgProgramAclTcamEngineAclKeyInfoEgr(A, key_f, &eacl_key_info, buffer);
            temp = buffer[0];
            buffer[0] = buffer[4];
            buffer[4] = temp;
            temp = buffer[1];
            buffer[1] = buffer[3];
            buffer[3] = temp;
            DIAG_INFO_U32_LIST(pos, "Lkup-Key", buffer, CTC_B2W_SIZE(160))
        }
        ltid = GetDbgProgramAclTcamEngineAclInfoEgr(V, ltid_f, &eacl_info);
        if (ltid >= 16 && ltid < 32)
        {
            DIAG_INFO_CHAR(pos, "key-type",STR_ARRAY(diag_map_acl_ltid,(ltid - 16)))
        }
        else
        {
            DIAG_INFO_UINT32(pos, "key-ltid", ltid)
        }
        if (key_len_type != 3)
        {
            DIAG_INFO_CHAR(pos, "key-size", STR_ARRAY(diag_acl_key_size,key_len_type))
        }
    }

    DIAG_INFO_XDATA(pos, GetDbgEpeAclInfo, epe_acl_proc_info)

    /* Exception Process */
    _sys_at_diag_pkt_tracce_exception_map(lchip,p_rslt,
                                               GetDbgEpeAclInfo(V, exceptionEn_f, &epe_acl_proc_info),
                                               GetDbgEpeAclInfo(V, exceptionIndex_f, &epe_acl_proc_info),
                                               GetDbgEpeAclInfo(V, exceptionSubIndex_f, &epe_acl_proc_info));
    return CTC_E_NONE;
}
STATIC int32
_sys_at_diag_pkt_trace_get_epe_copp_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_EPE;
    DbgEpeCoPPInfo_m copp_info;
    char *sys_diag_color[] = {"None", "Red", "Yellow", "Green"};

    cmd = DRV_IOR(DbgEpeCoPPInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &copp_info));

    /*copp*/
    if (!(GetDbgEpeCoPPInfo(V, valid_f,&copp_info)
        && GetDbgEpeCoPPInfo(V, coppValid_f, &copp_info)))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_EPE;
    DIAG_INFO_NONE(pos, "CoPP")
    DIAG_INFO_CHAR(pos, "copp-color", STR_ARRAY(sys_diag_color,GetDbgEpeCoPPInfo(V, color_f, &copp_info)))
    DIAG_INFO_UINT32(pos, "copp-length", GetDbgEpeCoPPInfo(V, coppLen_f, &copp_info))
    DIAG_INFO_UINT32(pos, "copp-ptr", GetDbgEpeCoPPInfo(V, coppPtr_f, &copp_info))
    DIAG_INFO_U32_HEX(pos, "copp-stats-ptr", GetDbgEpeCoPPInfo(V, coppStatsPtr_f, &copp_info))
    if(GetDbgEpeCoPPInfo(V, coppDrop_f, &copp_info))
    {
        DIAG_INFO_CHAR(pos, "copp-result", "DROP")
    }
    return CTC_E_NONE;
}

STATIC int32
_sys_at_diag_pkt_trace_get_epe_nh_map_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_EPE;
    uint32 value = 0;
    uint32 gport = 0;
    char* str_pl_op[] = {"NONE", "ROUTE", "BRIDGE", "BRIDGE-VPLS", "BRIDGE-INNER", "MIRROR", "ROUTE-NOTTL", "ROUTE-COMPACT"};
    DbgEpeNextHopInfo_m nh_info;

    sal_memset(&nh_info, 0, sizeof(DbgEpeNextHopInfo_m));
    cmd = DRV_IOR(DbgEpeNextHopInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &nh_info));
    if (!GetDbgEpeNextHopInfo(V, valid_f, &nh_info))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_EPE;
    DIAG_INFO_NONE(pos, "NextHop Mapper");

    cmd = DRV_IOR(DbgEpeHdrAdjInfo_t, DbgEpeHdrAdjInfo_valid_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &value));
    if (value)
    {
        cmd = DRV_IOR(DbgEpeHdrAdjInfo_t, DbgEpeHdrAdjInfo_localPhyPort_f);
        CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &value));
        cmd = DRV_IOR(DsDestPort_t, DsDestPort_globalDestPort_f);
        CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, value, DRV_CMD_PP_EN(cmd), &gport));
        if (SYS_DRV_IS_LINKAGG_PORT(gport))
        {
            DIAG_INFO_UINT32(pos, "linkagg-group", CTC_MAP_GPORT_TO_LPORT(gport))
        }
        DIAG_INFO_U32_HEX(pos, "dest-gport", SYS_MAP_DRV_GPORT_TO_CTC_GPORT(gport))
        p_rslt->dest_type = (value == MCHIP_CAP(SYS_CAP_RSV_PORT_TO_CPU)) ? CTC_DIAG_DEST_CPU : CTC_DIAG_DEST_NETWORK;
        p_rslt->port = SYS_MAP_DRV_GPORT_TO_CTC_GPORT(gport);
        p_rslt->flags |= CTC_DIAG_TRACE_RSTL_FLAG_PORT;
    }
    DIAG_INFO_UINT32(pos, "bypass-epe", GetDbgEpeNextHopInfo(V, bypassEpe_f, &nh_info))
    DIAG_INFO_UINT32(pos, "is-link-oam", GetDbgEpeNextHopInfo(V, linkOam_f, &nh_info))
    DIAG_INFO_UINT32(pos, "strip-hdr-mode", GetDbgEpeNextHopInfo(V, stripHdrMode_f, &nh_info))
    if (GetDbgEpeNextHopInfo(V, nhpCategoryValid_f, &nh_info))
    {
        DIAG_INFO_UINT32(pos, "nhp-category-id", GetDbgEpeNextHopInfo(V, nhpCategoryId_f, &nh_info))
    }
    if (GetDbgEpeNextHopInfo(V, policerValid0_f, &nh_info))
    {
        DIAG_INFO_UINT32(pos, "policer-ptr-0", GetDbgEpeNextHopInfo(V, policerPtr0_f, &nh_info))
    }
    if (GetDbgEpeNextHopInfo(V, policerValid1_f, &nh_info))
    {
        DIAG_INFO_UINT32(pos, "policer-ptr-1", GetDbgEpeNextHopInfo(V, policerPtr1_f, &nh_info))
    }
    value = GetDbgEpeNextHopInfo(V, destVlanPtr_f, &nh_info);
    if (value < 4096)
    {
        DIAG_INFO_UINT32(pos, "vlan-ptr", value)
    }
    if (GetDbgEpeNextHopInfo(V, outputSvlanIdValid_f, &nh_info))
    {
        DIAG_INFO_UINT32(pos, "output-svlan", GetDbgEpeNextHopInfo(V, outputSvlanId_f, &nh_info))
    }
    if (GetDbgEpeNextHopInfo(V, outputCvlanIdValid_f, &nh_info))
    {
        DIAG_INFO_UINT32(pos, "output-cvlan", GetDbgEpeNextHopInfo(V, outputCvlanId_f, &nh_info))
    }
    value = GetDbgEpeNextHopInfo(V, interfaceId_f, &nh_info);
    if (value)
    {
        p_rslt->l3if_id = value;
        p_rslt->flags |= CTC_DIAG_TRACE_RSTL_FLAG_L3IF_ID;
        DIAG_INFO_UINT32(pos, "interface-id", value)
    }
    value = GetDbgEpeNextHopInfo(V, logicDestPort_f, &nh_info);
    if (value)
    {
        DIAG_INFO_UINT32(pos, "logic-port", value)
    }
    if (GetDbgEpeNextHopInfo(V, nextApsBridgeEn_f, &nh_info))
    {
        DIAG_INFO_UINT32(pos, "next-aps-group", GetDbgEpeNextHopInfo(V, nextApsGroupId_f, &nh_info))
    }
    DIAG_INFO_CHAR(pos, "payload-opration", STR_ARRAY(str_pl_op,GetDbgEpeNextHopInfo(V, payloadOperation_f, &nh_info)))
    if (GetDbgEpeNextHopInfo(V, portLogEn_f, &nh_info))
    {
        DIAG_INFO_CHAR(pos, "port-log", "ENABLE")
    }
    if (GetDbgEpeNextHopInfo(V, portIsolateValid_f, &nh_info))
    {
        DIAG_INFO_CHAR(pos, "port-isolate", "ENABLE")
    }

    DIAG_INFO_XDATA(pos , GetDbgEpeNextHopInfo, nh_info)

    /* Drop Process */
    _sys_at_diag_pkt_tracce_drop_map(lchip,p_rslt,
                                          GetDbgEpeNextHopInfo(V, discard_f, &nh_info),
                                          GetDbgEpeNextHopInfo(V, discardType_f,  &nh_info));
    /* Exception Process */
    _sys_at_diag_pkt_tracce_exception_map(lchip,p_rslt,
                                               GetDbgEpeNextHopInfo(V, exceptionEn_f, &nh_info),
                                               GetDbgEpeNextHopInfo(V, exceptionIndex_f, &nh_info),
                                               GetDbgEpeNextHopInfo(V, exceptionSubIndex_f, &nh_info));
    return CTC_E_NONE;
}

STATIC int32
_sys_at_diag_pkt_trace_get_epe_oam_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint8 idx = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_EPE;
    uint32 value = 0;
    uint32 hdr_shareType = 0;
    char* lookup_result[4] = {"ETHER", "BFD", "TP", "Section"};
    char* key_name[4] = {"DsOamEthHashKey", "DsOamBfdHashKey",
                         "DsOamMplsLabelHashKey", "DsOamMplsSectionHashKey"};
    char *sys_diag_color[] = {"None", "Red", "Yellow", "Green"};

    DbgOamHashEngineFromEpeOam0Info_m epe_oam0_info;
    DbgOamHashEngineFromEpeOam1Info_m epe_oam1_info;
    DbgOamHashEngineFromEpeOam2Info_m epe_oam2_info;
    DbgEpeOamInfo_m dbg_epe_oam_info;
    uint8 key_type[3] = {0};
    uint8 hash_valid[3] = {0};
    uint8 confict[3] = {0};
    uint32 key_index[3] = {0};
    uint8 hash_resultValid[3] = {0};

    sal_memset(&epe_oam0_info, 0, sizeof(epe_oam0_info));
    cmd = DRV_IOR(DbgOamHashEngineFromEpeOam0Info_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &epe_oam0_info));
    sal_memset(&epe_oam1_info, 0, sizeof(epe_oam1_info));
    cmd = DRV_IOR(DbgOamHashEngineFromEpeOam1Info_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &epe_oam1_info));
    sal_memset(&epe_oam2_info, 0, sizeof(epe_oam2_info));
    cmd = DRV_IOR(DbgOamHashEngineFromEpeOam2Info_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &epe_oam2_info));
    sal_memset(&dbg_epe_oam_info, 0, sizeof(dbg_epe_oam_info));
    cmd = DRV_IOR(DbgEpeOamInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &dbg_epe_oam_info));

    if (!GetDbgEpeOamInfo(V, valid_f, &dbg_epe_oam_info))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_EPE;
    hash_resultValid[0] = GetDbgOamHashEngineFromEpeOam0Info(V, resultValid_f, &epe_oam0_info);
    confict[0] = GetDbgOamHashEngineFromEpeOam0Info(V, hashConflict_f, &epe_oam0_info);
    key_index[0] = GetDbgOamHashEngineFromEpeOam0Info(V, keyIndex_f, &epe_oam0_info);
    hash_valid[0] = GetDbgOamHashEngineFromEpeOam0Info(V, valid_f, &epe_oam0_info);

    hash_resultValid[1] = GetDbgOamHashEngineFromEpeOam1Info(V, resultValid_f, &epe_oam1_info);
    confict[1] = GetDbgOamHashEngineFromEpeOam1Info(V, hashConflict_f, &epe_oam1_info);
    key_index[1] = GetDbgOamHashEngineFromEpeOam1Info(V, keyIndex_f, &epe_oam1_info);
    hash_valid[1] = GetDbgOamHashEngineFromEpeOam1Info(V, valid_f, &epe_oam1_info);

    hash_resultValid[2] = GetDbgOamHashEngineFromEpeOam2Info(V, resultValid_f, &epe_oam2_info);
    confict[2] = GetDbgOamHashEngineFromEpeOam2Info(V, hashConflict_f, &epe_oam2_info);
    key_index[2] = GetDbgOamHashEngineFromEpeOam2Info(V, keyIndex_f, &epe_oam2_info);
    hash_valid[2] = GetDbgOamHashEngineFromEpeOam2Info(V, valid_f, &epe_oam2_info);

    key_type[0] = GetDbgOamHashEngineFromEpeOam0Info(V, oamKeyType_f, &epe_oam0_info);
    key_type[1] = GetDbgOamHashEngineFromEpeOam1Info(V, oamKeyType_f, &epe_oam1_info);
    key_type[2] = GetDbgOamHashEngineFromEpeOam2Info(V, oamKeyType_f, &epe_oam2_info);

    if (key_type[0] || key_type[1] || key_type[2])
    {
        char str[64] = {0};
        for (idx = 0; idx < 3; idx++)
        {
            if (!key_type[idx] || !hash_valid[idx])
            {
                continue;
            }
            /*OAMHASHTYPE_ETH = 0x1*/
            value = key_type[idx] - 0x1;
            sal_sprintf(str, "hash-%d", idx);
            DIAG_INFO_CHAR(pos, str, STR_ARRAY(lookup_result,value))
            if (confict[idx])
            {
                DIAG_INFO_CHAR(pos, "lookup-result", DIAG_LOOKUP_CONFLICT)
                DIAG_INFO_CHAR(pos, "key-name", STR_ARRAY(key_name,value))
                DIAG_INFO_UINT32(pos, "key-index", key_index[idx])
            }
            else if (hash_resultValid[idx])
            {
                DIAG_INFO_CHAR(pos, "lookup-result", DIAG_LOOKUP_HIT)
                DIAG_INFO_CHAR(pos, "key-name", STR_ARRAY(key_name,value))
                DIAG_INFO_UINT32(pos, "key-index", key_index[idx])
            }
            else
            {
                DIAG_INFO_CHAR(pos, "lookup-result", DIAG_LOOKUP_HIT_NONE)
            }
        }
    }

    if (hash_resultValid[0] || hash_resultValid[1] || hash_resultValid[2])
    {
        value = GetDbgEpeOamInfo(V, oamDestChipId_f, &dbg_epe_oam_info);
        if (GetDbgEpeOamInfo(V, mepEn_f, &dbg_epe_oam_info))
        {
            DIAG_INFO_CHAR(pos, "MEP", "HIT")
            DIAG_INFO_UINT32(pos, "master-chip-id", value)
            DIAG_INFO_UINT32(pos, "mep-index", GetDbgEpeOamInfo(V, mepIndex_f, &dbg_epe_oam_info))
        }
        if (GetDbgEpeOamInfo(V, mipEn_f, &dbg_epe_oam_info))
        {
            DIAG_INFO_CHAR(pos, "MIP", "HIT")
            DIAG_INFO_UINT32(pos, "master-chip-id", value)
        }
        value = GetDbgEpeOamInfo(V, rxOamTypeNew_f, &dbg_epe_oam_info);
        if (value)
        {
            /*RXOAMTYPE_TRILLBFD = 0xa*/
            char* oam_type[10] =
            {
                "ETHER OAM", "IP BFD", "PBT OAM", "PBBBSI", "PBBBV",
                "MPLS OAM", "MPLS BFD", "ACH OAM", "RSV", "TRILL BFD"
            };
            DIAG_INFO_CHAR(pos, "oam-type", STR_ARRAY(oam_type,(value - 1)))
        }
        if (GetDbgEpeOamInfo(V, mplsLmValid_f, &dbg_epe_oam_info) || GetDbgEpeOamInfo(V, etherLmValid_f, &dbg_epe_oam_info))
        {
            DIAG_INFO_CHAR(pos, "action", "read-LM")
            DIAG_INFO_CHAR(pos, "table-name", "DsOamLmStats")
            DIAG_INFO_UINT32(pos, "table-index", GetDbgEpeOamInfo(V, lmStatsIndex_f, &dbg_epe_oam_info))
        }
        if (GetDbgEpeOamInfo(V, lmStatsEn0_f, &dbg_epe_oam_info))
        {
            DIAG_INFO_CHAR(pos, "action", "write-LM")
            DIAG_INFO_CHAR(pos, "table-name", "DsOamLmStats")
            DIAG_INFO_UINT32(pos, "table-index", GetDbgEpeOamInfo(V, lmStatsPtr0_f, &dbg_epe_oam_info))
        }
        if (GetDbgEpeOamInfo(V, lmStatsEn1_f, &dbg_epe_oam_info))
        {
            DIAG_INFO_CHAR(pos, "action", "write-LM")
            DIAG_INFO_CHAR(pos, "table-name", "DsOamLmStats")
            DIAG_INFO_UINT32(pos, "table-index", GetDbgEpeOamInfo(V, lmStatsPtr1_f, &dbg_epe_oam_info))
        }
        if (GetDbgEpeOamInfo(V, lmStatsEn2_f, &dbg_epe_oam_info))
        {
            DIAG_INFO_CHAR(pos, "action", "write-LM")
            DIAG_INFO_CHAR(pos, "table-name", "DsOamLmStats")
            DIAG_INFO_UINT32(pos, "table-index", GetDbgEpeOamInfo(V, lmStatsPtr2_f, &dbg_epe_oam_info))
        }
        if (GetDbgEpeOamInfo(V, oamPrioValid_f, &dbg_epe_oam_info))
        {
            DIAG_INFO_UINT32(pos, "prio", GetDbgEpeOamInfo(V, oamPrio_f, &dbg_epe_oam_info))
        }
        DIAG_INFO_CHAR(pos, "color", STR_ARRAY(sys_diag_color,GetDbgEpeOamInfo(V, oamColor_f, &dbg_epe_oam_info)))
        if (GetDbgEpeOamInfo(V, oamCancelEditing_f, &dbg_epe_oam_info))
        {
            DIAG_INFO_CHAR(pos, "cancel-edit", DIAG_YES)
        }
    }

    cmd = DRV_IOR(DbgEpeHdrEditInfo_t, DbgEpeHdrEditInfo_valid_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &value));
    cmd = DRV_IOR(DbgEpeHdrEditInfo_t, DbgEpeHdrEditInfo_shareType_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &hdr_shareType));
    if ((value) && (4 == hdr_shareType))/*SHARETYPE_OAM = 4*/
    {
        DIAG_INFO_CHAR(pos, "destination", "OAM")
        CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_oam_rx_info(lchip, p_rslt));
    }

    return CTC_E_NONE;
}

STATIC int32
_sys_at_diag_pkt_trace_get_epe_xedit_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint8 pos = CTC_DIAG_TRACE_POS_EPE;
    uint32 cmd = 0;
    DbgEpeEgressEditInfo2_m DbgEpeEgressEditInfo2;
    DbgEpeXEgressEditInfo_m DbgEpeXEgressEditInfo;

    cmd = DRV_IOR(DbgEpeEgressEditInfo2_t, DRV_ENTRY_FLAG);
    DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &DbgEpeEgressEditInfo2);
    cmd = DRV_IOR(DbgEpeXEgressEditInfo_t, DRV_ENTRY_FLAG);
    DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &DbgEpeXEgressEditInfo);

    if (GetDbgEpeEgressEditInfo2(V, valid_f, &DbgEpeEgressEditInfo2))
    {
        p_rslt->position = CTC_DIAG_TRACE_POS_EPE;
        DIAG_INFO_NONE(pos, "xFlex Editing")
        DIAG_INFO_UINT32(pos, "xedit-ptr", GetDbgEpeEgressEditInfo2(V, xEditPtr_f, &DbgEpeEgressEditInfo2))
        DIAG_INFO_UINT32(pos, "xedit-type", GetDbgEpeXEgressEditInfo(V, xEditType_f, &DbgEpeXEgressEditInfo))
        DIAG_INFO_UINT32(pos, "outer-xedit-ptr", GetDbgEpeEgressEditInfo2(V, nhpOuterXEditPtr_f, &DbgEpeEgressEditInfo2))
        DIAG_INFO_UINT32(pos, "inner-xedit-ptr", GetDbgEpeEgressEditInfo2(V, nhpInnerXEditPtr_f, &DbgEpeEgressEditInfo2))
    }
    return CTC_E_NONE;
}


STATIC int32
_sys_at_diag_pkt_trace_get_epe_pkt_rw_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint8 pos = CTC_DIAG_TRACE_POS_EPE;
    uint32 cmd = 0;
    DbgEpePktRwInfo_m pkt_rw_info;
    cmd = DRV_IOR(DbgEpePktRwInfo_t, DRV_ENTRY_FLAG);
    DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &pkt_rw_info);
    if (GetDbgEpePktRwInfo(V, valid_f, &pkt_rw_info) && GetDbgEpePktRwInfo(V, isTransitNode_f, &pkt_rw_info))
    {
        p_rslt->position = CTC_DIAG_TRACE_POS_EPE;
        DIAG_INFO_NONE(pos, "Packet Rewrite")
        DIAG_INFO_CHAR(pos, "is-attach", GetDbgEpePktRwInfo(V, isAttach_f, &pkt_rw_info)? DIAG_YES: DIAG_NO)
        DIAG_INFO_UINT32(pos, "sec-tag-offset", GetDbgEpePktRwInfo(V, secTagOffset_f, &pkt_rw_info))
        DIAG_INFO_UINT32(pos, "old-l3checksum", GetDbgEpePktRwInfo(V, oldL3Checksum_f, &pkt_rw_info))
        DIAG_INFO_UINT32(pos, "new-l3checksum", GetDbgEpePktRwInfo(V, newL3Checksum_f, &pkt_rw_info))
        if (GetDbgEpePktRwInfo(V, l4ChecksumValid_f, &pkt_rw_info))
        {
            DIAG_INFO_UINT32(pos, "old-l4checksum", GetDbgEpePktRwInfo(V, oldL4Checksum_f, &pkt_rw_info))
            DIAG_INFO_UINT32(pos, "new-l4checksum", GetDbgEpePktRwInfo(V, newL4Checksum_f, &pkt_rw_info))
        }
    }
    return CTC_E_NONE;
}

STATIC int32
_sys_at_diag_pkt_trace_get_epe_dot1ae_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint64 val_u64 = 0;
    uint32 value[2] = {0};
    uint8 pos = CTC_DIAG_TRACE_POS_EPE;
    uint8 index = 0;
	uint32 tmp_value =0;
    DbgXSecTxInfo_m dbg_macsec_info;

    /*macsec-tx process*/
    for (index = 0; index < MCHIP_CAP(SYS_CAP_DP_MAX_NUM); index++)/* DP0 + DP1*/
    {
        sal_memset(&dbg_macsec_info, 0, sizeof(DbgXSecTxInfo_m));
        cmd = DRV_IOR(DbgXSecTxInfo_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_DP_EN(cmd, index), &dbg_macsec_info));

        if ((GetDbgXSecTxInfo(V, valid_f, &dbg_macsec_info)) && (DIAG_XSEC_ENCRYTP == GetDbgXSecTxInfo(V, opType_f,  &dbg_macsec_info)))
        {
            p_rslt->position = CTC_DIAG_TRACE_POS_EPE;
            DIAG_INFO_NONE(pos, "Dot1ae Tx")
            DIAG_INFO_UINT32(pos, "macsec-channel", GetDbgXSecTxInfo(V, channelId_f, &dbg_macsec_info))
            DIAG_INFO_UINT32(pos, "sc-index", GetDbgXSecTxInfo(V, cryptoSc_f, &dbg_macsec_info))
            DIAG_INFO_UINT32(pos, "bypass-macsec-proc", GetDbgXSecTxInfo(V, bypassXSecTxProc_f, &dbg_macsec_info))
            DIAG_INFO_UINT32(pos, "controlled-port-enable", GetDbgXSecTxInfo(V, controlledPortEnabled_f, &dbg_macsec_info))
            DIAG_INFO_UINT32(pos, "protect-frames", GetDbgXSecTxInfo(V, protectFrames_f, &dbg_macsec_info))
            DIAG_INFO_UINT32(pos, "encodingSa", GetDbgXSecTxInfo(V, encodingSa_f, &dbg_macsec_info))
            DIAG_INFO_UINT32(pos, "sa-in-use", GetDbgXSecTxInfo(V, saInUse_f, &dbg_macsec_info))
            DIAG_INFO_UINT32(pos, "macsec-short-length", GetDbgXSecTxInfo(V, sl_f, &dbg_macsec_info))
            DIAG_INFO_UINT32(pos, "sec-tag-length", GetDbgXSecTxInfo(V, secTagLen_f, &dbg_macsec_info))
            DIAG_INFO_UINT32(pos, "sec-tag-offset", GetDbgXSecTxInfo(V, secTagOffset_f, &dbg_macsec_info))
            DIAG_INFO_UINT32(pos, "macsec-tci", GetDbgXSecTxInfo(V, macsecTci_f, &dbg_macsec_info))
            DIAG_INFO_UINT32(pos, "is-udp-ctcsec", GetDbgXSecTxInfo(V, isUdpCtcSec_f, &dbg_macsec_info))
            DIAG_INFO_UINT32(pos, "is-vxlan-ctcsec", GetDbgXSecTxInfo(V, isVxlanCtcSec_f, &dbg_macsec_info))
            DIAG_INFO_UINT32(pos, "is-ip-ctcsec", GetDbgXSecTxInfo(V, isIpCtcSec_f, &dbg_macsec_info))
            DIAG_INFO_UINT32(pos, "is-ip-gre-ctcsec", GetDbgXSecTxInfo(V, isIpGreCtcSec_f, &dbg_macsec_info))
            GetDbgXSecTxInfo(A, xpn_f, &dbg_macsec_info, value);
            val_u64 = value[1];
            val_u64 = (val_u64 << 32) | value[0];
            DIAG_INFO_UINT64(pos, "macsec-pn", val_u64)

            DIAG_INFO_UINT32(pos, "macsec-sop-discard", GetDbgXSecTxInfo(V, sopDiscard_f, &dbg_macsec_info))
            DIAG_INFO_UINT32(pos, "macsec-eop-discard", GetDbgXSecTxInfo(V, eopDiscard_f, &dbg_macsec_info))
            DIAG_INFO_UINT32(pos, "need-encrypt-process", GetDbgXSecTxInfo(V, needEncryptProcess_f, &dbg_macsec_info))
            DIAG_INFO_UINT32(pos, "bypass-encrypt", GetDbgXSecTxInfo(V, bypassEncrypt_f, &dbg_macsec_info))

            if (GetDbgXSecTxInfo(V, scStatsValid_f, &dbg_macsec_info))
            {
                tmp_value = GetDbgXSecTxInfo(V, scStatsType_f,  &dbg_macsec_info);
                DIAG_INFO_CHAR(pos, "sc-stats", (tmp_value == 2) ? "pkt-encrypted" : ( (tmp_value == 1)? "pkt-protected" : "sa-not-in-use"))
            }

            if (GetDbgXSecTxInfo(V, secYStatsValid_f, &dbg_macsec_info))
            {
                tmp_value = GetDbgXSecTxInfo(V, secYStatsType_f,  &dbg_macsec_info);
                DIAG_INFO_CHAR(pos, "secY-stats", (tmp_value == 2) ? "pkt-length-error" : ( (tmp_value == 1)? "no-protect-frames" : "port-disable"))
            }

            if (GetDbgXSecTxInfo(V, secYByteStatsValid_f, &dbg_macsec_info))
            {
                tmp_value = GetDbgXSecTxInfo(V, secYByteStatsType_f,  &dbg_macsec_info);
                DIAG_INFO_CHAR(pos, "secY-byte-stats", tmp_value ? "encrypted-bytes" : "protected-bytes")
            }

            if (GetDbgXSecTxInfo(V, chanStatsValid_f, &dbg_macsec_info))
            {
                tmp_value = GetDbgXSecTxInfo(V, chanStatsType_f,  &dbg_macsec_info);
                DIAG_INFO_CHAR(pos, "chan-stats", (tmp_value == 2) ? "cfg-error" : ( (tmp_value == 1)? "discard" : "bypass"))
            }

        }
    }
    return CTC_E_NONE;
}

STATIC int32
_sys_at_diag_pkt_trace_get_epe_edit_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint8  l3edit_type = 0;
    //uint8  l2edit_type = 0;
    uint8  nhp_middleEditPtrEn = 0;
    uint8  next_edit_valid = 0;
    uint8  vlan_edit_valid = 0;
    uint8  l2edit_is6w = 0;
    uint8  outer_edit_ptr_x_valid = 0;
    uint32 cmd = 0;
    uint32 value = 0;
    uint32 value1 = 0;
    uint32 label = 0;
    uint32 edit_valid = 0;
    uint32 nhp_nhpIs8w = 0;
    uint32 nhpShareType = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_EPE;
    //uint8  is_mac_swap = 0, is_eth_edit;
    uint32 dsNextHopInternalBase = 0;
    uint32 nhpOuterEditPtrType = 0;
    uint32 flex_edit_ptr = 0;
    uint32 snat_edit_ptr = 0;
    uint32 flex_edit_base = 0;
    hw_mac_addr_t hw_mac = {0};
    uint8 pp_id = lchip - SYS_PP_BASE(lchip);
    uint32 met_info1_tbl[4] = {DbgFwdMetFifoInfo10_t,DbgFwdMetFifoInfo11_t,DbgFwdMetFifoInfo12_t,DbgFwdMetFifoInfo13_t};
    char *sys_diag_vlan_action[] = {"None", "Add", "Delete", "Replace"};
    char* l3_edit[] =
    {
        "NONE",
        "ADDIP4",
        "ADDIP44X",
        "ADDIP6",
        "MPLS1X",
        "MPLS2X",
        "MPLS4X",
        "ADDRAW",
        "RWIP41X",
        "RWIP4",
        "RWIP6",
        "RWFLEX",
        "INSFLEX",
        "DELMPLS",
        "DELFLEX",
        "LOOPBACK",
        "ADDTRILL",
        "RWIP68X",
        "ADDIP68X",
        "RWIP62X"
    };
    char* l3_edit_name[] =
    {
        "",
        "DsL3EditAddIp4",
        "DsL3EditAddIp44X",
        "DsL3EditAddIp6",
        "DsL3EditAddMpls1X",
        "DsL3EditAddMpls2X",
        "DsL3EditAddMpls4X",
        "DsL3EditAddRaw",
        "DsL3EditRwIp41X",
        "DsL3EditRwIp4",
        "DsL3EditRwIp6",
        "DsL3EditRwFlex",
        "DsL3EditInsFlex",
        "DsL3EditDelMpls",
        "DsL3EditDelFlex",
        "DsL3EditLoopback",
        "DsL3EditAddTrill",
        "DsL3EditAddIp6ExtHeader",
        "DsL3EditAddIp6ExtHeader",
        "DsL3EditRwIp62X"
    };

    char* l2_edit[] = {
        "NONE",
        "ADDETH1X",
        "ADDETH2X",
        "ADDRAW",
        "AUTOETH1X",
        "AUTOETH2X",
        "","","",
        "RWETH1X",
        "RWETH2X",
        "","","",
        "GEMPORT",
        "LOOPBACK"
    };
    char* l2_edit_name[] = {
        "",
        "DsL2EditAddEth1X",
        "DsL2EditAddEth2X",
        "DsL2EditAddRaw",
        "DsL2EditAutoEth1X",
        "DsL2EditAutoEth2X",
        "","","",
        "DsL2EditRwEth1X",
        "DsL2EditRwEth2X",
        "","","",
        "DsL2EditGemPort",
        "DsL2EditLoopback"
    };

    DsNextHop8W_m nexthop_8w;
    DsNextHop4W_m nexthop_4w;
    DsL2EditAddEth1X_m l2edit_eth3w;
    DsL2Edit6WOuter_m l2edit_6w_outer;
    DsL2EditAddEth2X_m l2edit_add_eth2X;
    DsL3Edit6W3rd_m l3edit_6w3rd;
    DsL3EditAddMpls1X_m l3edit_mpls1X;
    DsL3Edit12W_m l3edit_12w;
    DbgEpeHdrAdjInfo_m hdr_adj_info;
    DbgEpeNextHopInfo_m nexthop_info;
    DbgEpePldProcInfo_m payload_info;
    DbgEpeEgressEditInfo_m egress_edit_info;
    EpeNextHopCtl_m epe_nh_ctl;

    uint32 next_edit_ptr = 0;
    uint32 next_edit_type = 0;
    uint32 do_l2_edit = 0;
    uint32 l2_edit_ptr = 0;
    uint32 nhp_outerEditPtr = 0;
    uint32 l2_individual_memory = 0;
    uint32 l3edit_l3RewriteType = 0;
    uint32 l2edit_l2RewriteType = 0;
    uint32 edit_outerEditPipe1Exist = 0;
    uint32 edit_nhpOuterEditLocation = 0;
    uint32 outer_edit_ptr_x = 0;
    //uint8  nhp_innerEditPtrOffset = 0;
    void* ds = NULL;

    sal_memset(&nexthop_8w, 0, sizeof(nexthop_8w));
    sal_memset(&nexthop_4w, 0, sizeof(nexthop_4w));
    sal_memset(&l2edit_eth3w, 0, sizeof(l2edit_eth3w));
    sal_memset(&l3edit_mpls1X, 0, sizeof(l3edit_mpls1X));
    sal_memset(&l2edit_6w_outer, 0, sizeof(l2edit_6w_outer));
    sal_memset(&l2edit_add_eth2X, 0, sizeof(l2edit_add_eth2X));
    sal_memset(&l3edit_6w3rd, 0, sizeof(l3edit_6w3rd));

    /*DbgEpeHdrAdjInfo*/
    sal_memset(&hdr_adj_info, 0, sizeof(hdr_adj_info));
    cmd = DRV_IOR(DbgEpeHdrAdjInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &hdr_adj_info));
    if (GetDbgEpeHdrAdjInfo(V, bypassAll_f, &hdr_adj_info) || GetDbgEpeHdrAdjInfo(V, bypassEpe_f, &hdr_adj_info) || (0x3FFFF == GetDbgEpeHdrAdjInfo(V, nextHopPtr_f, &hdr_adj_info)))
    {
        return CTC_E_NONE;
    }
    sal_memset(&nexthop_info, 0, sizeof(nexthop_info));
    cmd = DRV_IOR(DbgEpeNextHopInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &nexthop_info));
    sal_memset(&payload_info, 0, sizeof(payload_info));
    cmd = DRV_IOR(DbgEpePldProcInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &payload_info));
    sal_memset(&egress_edit_info, 0, sizeof(egress_edit_info));
    cmd = DRV_IOR(DbgEpeEgressEditInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &egress_edit_info));

    edit_valid = GetDbgEpeEgressEditInfo(V, valid_f, &egress_edit_info);
    edit_outerEditPipe1Exist = GetDbgEpeEgressEditInfo(V, outerEditPipe1Exist_f, &egress_edit_info);
    edit_nhpOuterEditLocation = GetDbgEpeNextHopInfo(V, nhpOuterEditLocation_f, &nexthop_info);
    nhp_outerEditPtr = GetDbgEpeNextHopInfo(V, nhpOuterEditPtr_f, &nexthop_info);
    //nhp_innerEditPtrOffset = GetDbgEpeNextHopInfo(V, innerEditPtrOffset_f, &nexthop_info);
    l3edit_l3RewriteType = GetDbgEpeEgressEditInfo(V, l3EditType_f, &egress_edit_info);
    l2edit_l2RewriteType = GetDbgEpeEgressEditInfo(V, l2EditType_f, &egress_edit_info);

    if (!edit_valid && !GetDbgEpeNextHopInfo(V, valid_f, &nexthop_info))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_EPE;

    DIAG_INFO_NONE(pos, "Flex Editing")

    DIAG_INFO_UINT32(pos, "edit-template-id0", GetDbgEpeNextHopInfo(V, flexEditTemplateId0_f, &nexthop_info))
    DIAG_INFO_UINT32(pos, "edit-template-id1", GetDbgEpeNextHopInfo(V, flexEditTemplateId1_f, &nexthop_info))
    DIAG_INFO_UINT32(pos, "edit-template-id2", GetDbgEpeNextHopInfo(V, flexEditTemplateId2_f, &nexthop_info))
    DIAG_INFO_UINT32(pos, "edit-template-id3", GetDbgEpeNextHopInfo(V, flexEditTemplateId3_f, &nexthop_info))

    snat_edit_ptr = GetDbgEpeNextHopInfo(V, snatEditPtr_f, &nexthop_info);
    flex_edit_ptr = GetDbgEpeNextHopInfo(V, flexEditPtr_f, &nexthop_info);
    cmd = DRV_IOR(EpeNextHopCtl_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &epe_nh_ctl));
    if (0 != snat_edit_ptr)
    {
        flex_edit_base = GetEpeNextHopCtl(V, snatEditPtrBase_f, &epe_nh_ctl);
        DIAG_INFO_U32_HEX(pos, "inner-edit-ptr", flex_edit_base + snat_edit_ptr)
        DIAG_INFO_UINT32(pos, "inner-edit-ptr-type", GetEpeNextHopCtl(V, snatEditPtrType_f, &epe_nh_ctl))
    }
    else if (0 != flex_edit_ptr)
    {

        flex_edit_base = GetEpeNextHopCtl(V, flexEditPtrBase_f, &epe_nh_ctl);
        switch(GetEpeNextHopCtl(V, flexEditPtrMode_f, &epe_nh_ctl))
        {
            case 1:
            {
                DIAG_INFO_U32_HEX(pos, "inner-edit-ptr", flex_edit_base + flex_edit_ptr)
                DIAG_INFO_UINT32(pos, "inner-edit-ptr-type", GetEpeNextHopCtl(V, flexEditPtrType_f, &epe_nh_ctl))
            }
            break;
            case 2:
            {
                DIAG_INFO_U32_HEX(pos, "outer-edit-ptr", flex_edit_base + flex_edit_ptr)
                DIAG_INFO_UINT32(pos, "outer-edit-ptr-type", GetEpeNextHopCtl(V, flexEditPtrType_f, &epe_nh_ctl))
            }
            break;
            case 3:
            {
                if (CTC_IS_BIT_SET(flex_edit_ptr, 14))
                {
                    DIAG_INFO_U32_HEX(pos, "outer-edit-ptr", flex_edit_base + (flex_edit_ptr&0x1FFF))
                    DIAG_INFO_UINT32(pos, "outer-edit-ptr-type", CTC_IS_BIT_SET(flex_edit_ptr, 13))
                }
                else
                {
                    DIAG_INFO_U32_HEX(pos, "inner-edit-ptr", flex_edit_base + (flex_edit_ptr&0x1FFF))
                    DIAG_INFO_UINT32(pos, "inner-edit-ptr-type", CTC_IS_BIT_SET(flex_edit_ptr, 13))
                }
            }
            break;
            default:
            break;
        }
    }

    DIAG_INFO_NONE(pos, "Layer3 Packet Editing")

    if (GetDbgEpePldProcInfo(V, valid_f, &payload_info))
    {

        if (GetDbgEpePldProcInfo(V, newTtlValid_f, &payload_info))
        {
            DIAG_INFO_UINT32(pos, "new-ttl", GetDbgEpePldProcInfo(V, newTtl_f, &payload_info))
        }
        if (GetDbgEpePldProcInfo(V, newDscpValid_f, &payload_info))
        {
            DIAG_INFO_UINT32(pos, "new-dscp", GetDbgEpePldProcInfo(V, newDscp_f, &payload_info))
        }
    }

    cmd = DRV_IOR(EpeHdrAdjustCtl_t, EpeHdrAdjustCtl_dsNextHopInternalBase_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &dsNextHopInternalBase));

    nhp_nhpIs8w = GetDbgEpeNextHopInfo(V, nhpIs8w_f, &nexthop_info);
    value = GetDbgEpeHdrAdjInfo(V, nextHopPtr_f, &hdr_adj_info);
    if ((value >> 4) != dsNextHopInternalBase)
    {
        cmd = DRV_IOR(DsNextHop8W_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, (value >> 1) << 1, DRV_CMD_PP_EN(cmd), &nexthop_8w));

        if (!nhp_nhpIs8w)
        {
            if (CTC_IS_BIT_SET(value, 0))
            {
                sal_memcpy((uint8*)&nexthop_4w, (uint8*)&nexthop_8w + DRV_TABLE_ENTRY_SIZE(lchip, DsNextHop4W_t), DRV_TABLE_ENTRY_SIZE(lchip, DsNextHop4W_t));
            }
            else
            {
                sal_memcpy((uint8*)&nexthop_4w, (uint8*)&nexthop_8w , DRV_TABLE_ENTRY_SIZE(lchip, DsNextHop4W_t));
            }
        }
    }
    else
    {
        cmd = DRV_IOR(EpeNextHopInternal_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, (value & 0xF) >> 1, DRV_CMD_PP_EN(cmd), &nexthop_8w));
        if (!nhp_nhpIs8w)
        {
            if (CTC_IS_BIT_SET(value & 0xF , 0))
            {
                sal_memcpy((uint8*)&nexthop_4w, (uint8*)&nexthop_8w + DRV_TABLE_ENTRY_SIZE(lchip, DsNextHop4W_t), DRV_TABLE_ENTRY_SIZE(lchip, DsNextHop4W_t));
            }
            else
            {
                sal_memcpy((uint8*)&nexthop_4w, (uint8*)&nexthop_8w , DRV_TABLE_ENTRY_SIZE(lchip, DsNextHop4W_t));
            }
        }
    }

    if (nhp_nhpIs8w)
    {
        nhpShareType = GetDsNextHop8W(V, shareType_f, &nexthop_8w);
    }
    else
    {
        nhpShareType = GetDsNextHop4W(V, shareType_f, &nexthop_4w);
    }

    /*NHPSHARETYPE_L2EDIT_PLUS_L3EDIT_OP = 0*/
    if ((0 == nhpShareType) || (nhp_nhpIs8w))
    {
        if (nhp_nhpIs8w)
        {
            nhpOuterEditPtrType = GetDsNextHop8W(V, outerEditPtrType_f, &nexthop_8w);
        }
        else
        {
            nhpOuterEditPtrType = GetDsNextHop4W(V, outerEditPtrType_f, &nexthop_4w);
        }
        /*inner edit*/
        value = GetDbgEpeNextHopInfo(V, nhpInnerEditPtr_f, &nexthop_info);
        if (edit_valid
            && GetDbgEpeEgressEditInfo(V, innerEditExist_f, &egress_edit_info))
        {
            char edit_table_name_inner[CTC_DIAG_TRACE_STR_LEN] = {0};
            if (GetDbgEpeEgressEditInfo(V, nhpInnerEditPtrEn_f, &egress_edit_info) &&
                GetDbgEpeEgressEditInfo(V, innerEditPtrType_f, &egress_edit_info))
            {
                uint32 l3edit_type_inner = l3edit_l3RewriteType;
                if (l3edit_l3RewriteType == DRV_ENUM(DRV_L3EDITTYPE_MPLS1X) ||
                    l3edit_l3RewriteType == DRV_ENUM(DRV_L3EDITTYPE_MPLS2X) ||
                    l3edit_l3RewriteType == DRV_ENUM(DRV_L3EDITTYPE_MPLS4X))
                {
                    cmd = DRV_IOR(DsL3EditAddMpls1X_t, DRV_ENTRY_FLAG);
                    CTC_ERROR_RETURN(DRV_IOCTL(lchip, value, DRV_CMD_PP_EN(cmd), &l3edit_mpls1X));
                    label = GetDsL3EditAddMpls1X(V, label_f, &l3edit_mpls1X);
                    DIAG_INFO_UINT32(pos, "new-label", label)
                }
                /* Use table id to read edit type,not for comtent */
                if(!(value % 4)) /* 4X format */
                {
                    cmd = DRV_IOR(DsL3EditAddIp44X0_t, DRV_ENTRY_FLAG);
                    CTC_ERROR_RETURN(DRV_IOCTL(lchip, value, DRV_CMD_PP_EN(cmd), &l3edit_12w));
                    l3edit_type_inner = GetDsL3Edit12W(V, l3EditType_f, &l3edit_12w);
                }
                else if(!(value % 2)) /* 2X format */
                {
                    cmd = DRV_IOR(DsL3EditAddIp40_t, DRV_ENTRY_FLAG);
                    CTC_ERROR_RETURN(DRV_IOCTL(lchip, value, DRV_CMD_PP_EN(cmd), &l3edit_12w));
                    l3edit_type_inner = GetDsL3Edit6W(V, l3EditType_f, &l3edit_12w);
                }
                else /* 1X format */
                {
                    cmd = DRV_IOR(DsL3EditRwIp41X0_t, DRV_ENTRY_FLAG);
                    CTC_ERROR_RETURN(DRV_IOCTL(lchip, value, DRV_CMD_PP_EN(cmd), &l3edit_12w));
                    l3edit_type_inner = GetDsL3Edit3W(V, l3EditType_f, &l3edit_12w);
                }
                sal_sprintf(edit_table_name_inner, "%s0",STR_ARRAY(l3_edit_name,l3edit_type_inner));
                DIAG_INFO_UINT32(pos, "edit-table-index", value)
                DIAG_INFO_CHAR(pos, "edit-table-name",edit_table_name_inner)
            }
            else if (GetDbgEpeEgressEditInfo(V, nhpInnerEditPtrEn_f, &egress_edit_info) &&
                     !GetDbgEpeEgressEditInfo(V, innerEditPtrType_f, &egress_edit_info))
            {
                DIAG_INFO_CHAR(pos, "inner-l2edit", STR_ARRAY(l2_edit,l2edit_l2RewriteType))
                DIAG_INFO_UINT32(pos, "edit-table-index", value)
                sal_sprintf(edit_table_name_inner, "%s0",STR_ARRAY(l2_edit_name,l2edit_l2RewriteType));
                DIAG_INFO_CHAR(pos, "edit-table-name", edit_table_name_inner)
            }
        }

        nhp_middleEditPtrEn = GetDbgEpeEgressEditInfo(V, nhpMiddleEditPtrEn_f, &egress_edit_info);
        if ((nhp_middleEditPtrEn || GetDbgEpeEgressEditInfo(V, nhpOuterEditPtrEn_f, &egress_edit_info)) && edit_valid)
        {
            /*outer pipeline0*/
            if (edit_outerEditPipe1Exist)
            {
                cmd = DRV_IOR(DsL3Edit12W_t, DRV_ENTRY_FLAG);
                CTC_ERROR_RETURN(DRV_IOCTL(lchip, (nhp_outerEditPtr >> 2) << 2, DRV_CMD_PP_EN(cmd), &l3edit_12w));
                l3edit_type = GetDsL3Edit12W(V, l3EditType_f, &egress_edit_info);
                if (GetDbgEpeEgressEditInfo(V, nhpOuterEditPtrEn_f, &egress_edit_info) &&
                    nhpOuterEditPtrType && !edit_nhpOuterEditLocation)  /* share memory */
                {
                    if (!(nhp_outerEditPtr & 0x3) && GetDbgEpeEgressEditInfo(V, innerEditExist_f, &egress_edit_info) &&
                        GetDbgEpeEgressEditInfo(V, innerEditPtrType_f, &egress_edit_info) &&
                        GetDbgEpeEgressEditInfo(V, innerEditType_f, &egress_edit_info) == DIAG_EDITTYPE_TYPE8X) /*srv6*/
                    {
                        DIAG_INFO_CHAR(pos, "outer-srv6-edit",STR_ARRAY(l3_edit,l3edit_l3RewriteType))
                        DIAG_INFO_UINT32(pos, "edit-table-index", nhp_outerEditPtr >> 2)
                        DIAG_INFO_CHAR(pos, "edit-table-name", STR_ARRAY(l3_edit_name,l3edit_l3RewriteType))
                        if (GetDsL3Edit12W(V, nextEditPtrValid_f, &l3edit_12w))
                        {
                            next_edit_ptr = GetDsL3Edit12W(V, outerEditPtr_f, &l3edit_12w);
                            next_edit_type = GetDsL3Edit12W(V, outerEditPtrType_f, &l3edit_12w);
                            next_edit_valid = 1;
                        }
                        else if (GetDsL3Edit12W(V, outerEditPtr_f, &l3edit_12w))
                        {
                            next_edit_ptr = GetDsL3Edit12W(V, outerEditPtr_f, &l3edit_12w);
                            next_edit_type = 1;
                            next_edit_valid = 1;
                        }
                        else
                        {
                            next_edit_ptr = 0;
                            next_edit_valid = 0;
                        }
                    }
                    else if (!(nhp_outerEditPtr & 0x3) &&
                                (l3edit_type == DIAG_L3EDITTYPE_ADDIP44X    ||
                                 l3edit_type == DIAG_L3EDITTYPE_ADDIP6      ||
                                 l3edit_type == DIAG_L3EDITTYPE_RWIP6       ||
                                 l3edit_type == DIAG_L3EDITTYPE_MPLS4X      ||
                                 l3edit_type == DIAG_L3EDITTYPE_RWFLEX      ||
                                 l3edit_type == DIAG_L3EDITTYPE_INSFLEX     ||
                                 l3edit_type == DIAG_L3EDITTYPE_DELFLEX))
                    {
                        DIAG_INFO_CHAR(pos, "outer-edit", STR_ARRAY(l3_edit,l3edit_l3RewriteType))
                        DIAG_INFO_UINT32(pos, "edit-table-index", nhp_outerEditPtr >> 2)
                        DIAG_INFO_CHAR(pos, "edit-table-name", STR_ARRAY(l3_edit_name,l3edit_l3RewriteType))
                        if (GetDsL3Edit12W(V, nextEditPtrValid_f, &l3edit_12w))
                        {
                            next_edit_ptr = GetDsL3Edit12W(V, outerEditPtr_f, &l3edit_12w);
                            next_edit_type = GetDsL3Edit12W(V, outerEditPtrType_f, &l3edit_12w);
                            next_edit_valid = 1;
                        }
                        else if (GetDsL3Edit12W(V, outerEditPtr_f, &l3edit_12w))
                        {
                            next_edit_ptr = GetDsL3Edit12W(V, outerEditPtr_f, &l3edit_12w);
                            next_edit_type = 1;
                            next_edit_valid = 1;
                        }
                        else
                        {
                            next_edit_ptr = 0;
                            next_edit_valid = 0;
                        }
                    }
                    else if (CTC_IS_BIT_SET(nhp_outerEditPtr, 0))
                    {
                        uint32 l3edit_l3RewriteType_outer = l3edit_l3RewriteType;
                        DIAG_INFO_CHAR(pos, "outer-edit", STR_ARRAY(l3_edit,l3edit_l3RewriteType))
                        DIAG_INFO_UINT32(pos, "edit-table-index", nhp_outerEditPtr)
                        if (!CTC_IS_BIT_SET(nhp_outerEditPtr, 1))
                        {
                            ds = (uint8*)&l3edit_12w + DRV_TABLE_ENTRY_SIZE(lchip, DsL3Edit3W_t);
                            l3edit_l3RewriteType_outer = GetDsL3Edit3W(V, l3EditType_f, ds);
                        }
                        else
                        {
                            ds = (uint8*)&l3edit_12w + 3 * DRV_TABLE_ENTRY_SIZE(lchip, DsL3Edit3W_t);
                            l3edit_l3RewriteType_outer = GetDsL3Edit3W(V, l3EditType_f, ds);
                        }
                        DIAG_INFO_CHAR(pos, "edit-table-name", STR_ARRAY(l3_edit_name,l3edit_l3RewriteType_outer))
                        if (l3edit_l3RewriteType == DIAG_L3EDITTYPE_MPLS1X)
                        {
                            DIAG_INFO_UINT32(pos, "new-label", GetDsL3EditAddMpls1X(V, label_f, ds))
                        }
                        if (GetDsL3Edit3W(V, nextEditPtrValid_f, ds))
                        {
                            next_edit_ptr = GetDsL3Edit3W(V, outerEditPtr_f, ds);
                            next_edit_type = GetDsL3Edit3W(V, outerEditPtrType_f, ds);
                            next_edit_valid = 1;
                        }
                        else if (GetDsL3Edit3W(V, outerEditPtr_f, ds))
                        {
                            next_edit_ptr = GetDsL3Edit3W(V, outerEditPtr_f, ds);
                            next_edit_type = 1;
                            next_edit_valid = 1;
                        }
                        else
                        {
                            next_edit_ptr = 0;
                            next_edit_valid = 0;
                        }
                    }
                    else
                    {
                        uint32 l3edit_l3RewriteType_outer = l3edit_l3RewriteType;
                        DIAG_INFO_CHAR(pos, "outer-edit", STR_ARRAY(l3_edit,l3edit_l3RewriteType))
                        if (!CTC_IS_BIT_SET(nhp_outerEditPtr, 1))
                        {
                            ds = (uint8*)&l3edit_12w;
                            l3edit_l3RewriteType_outer = GetDsL3Edit12W(V, l3EditType_f, ds);
                        }
                        else
                        {
                            ds = (uint8*)&l3edit_12w + DRV_TABLE_ENTRY_SIZE(lchip, DsL3Edit6W_t);
                            l3edit_l3RewriteType_outer = GetDsL3Edit6W(V, l3EditType_f, ds);
                        }
                        if (l3edit_l3RewriteType == DIAG_L3EDITTYPE_MPLS1X)
                        {
                            DIAG_INFO_UINT32(pos, "new-label", GetDsL3EditAddMpls1X(V, label_f, ds))
                        }
                        DIAG_INFO_UINT32(pos, "edit-table-index", nhp_outerEditPtr)
                        DIAG_INFO_CHAR(pos, "edit-table-name", STR_ARRAY(l3_edit_name,l3edit_l3RewriteType_outer))
                        l3edit_type = GetDsL3Edit6W(V, l3EditType_f, ds);
                        if (l3edit_type == DIAG_L3EDITTYPE_ADDIP4   ||
                            l3edit_type == DIAG_L3EDITTYPE_MPLS2X   ||
                            l3edit_type == DIAG_L3EDITTYPE_ADDRAW   ||
                            l3edit_type == DIAG_L3EDITTYPE_RWIP4)
                        {
                            if (GetDsL3Edit6W(V, nextEditPtrValid_f, ds))
                            {
                                next_edit_ptr = GetDsL3Edit6W(V, outerEditPtr_f, ds);
                                next_edit_type = GetDsL3Edit6W(V, outerEditPtrType_f, ds);
                                next_edit_valid = 1;
                            }
                            else if (GetDsL3Edit6W(V, outerEditPtr_f, ds))
                            {
                                next_edit_ptr = GetDsL3Edit6W(V, outerEditPtr_f, ds);
                                next_edit_type = 1;
                                next_edit_valid = 1;
                            }
                            else
                            {
                                next_edit_ptr = 0;
                                next_edit_valid = 0;
                            }
                        }
                        else if (l3edit_type == DIAG_L3EDITTYPE_RWIP62X)    //construct 12w to process
                        {
                            ;
                        }
                        else
                        {
                            if (GetDsL3Edit3W(V, nextEditPtrValid_f, ds))
                            {
                                next_edit_ptr = GetDsL3Edit3W(V, outerEditPtr_f, ds);
                                next_edit_type = GetDsL3Edit3W(V, outerEditPtrType_f, ds);
                                next_edit_valid = 1;
                            }
                            else if (GetDsL3Edit3W(V, outerEditPtr_f, ds))
                            {
                                next_edit_ptr = GetDsL3Edit3W(V, outerEditPtr_f, ds);
                                next_edit_type = 1;
                                next_edit_valid = 1;
                            }
                            else
                            {
                                next_edit_ptr = 0;
                                next_edit_valid = 0;
                            }
                        }
                    }
                }
                else if (GetDbgEpeEgressEditInfo(V, nhpOuterEditPtrEn_f, &egress_edit_info) &&
                         nhpOuterEditPtrType && edit_nhpOuterEditLocation)
                {
                    next_edit_ptr = nhp_outerEditPtr;
                    next_edit_type = nhpOuterEditPtrType;
                    next_edit_valid = 1;
                }
                else if (GetDbgEpeEgressEditInfo(V, nhpOuterEditPtrEn_f, &egress_edit_info) &&
                         !nhpOuterEditPtrType && !edit_nhpOuterEditLocation)    /*share memory*/
                {
                    do_l2_edit = 1;
                    l2_edit_ptr = nhp_outerEditPtr;
                    l2_individual_memory = 0;
                    if (CTC_IS_BIT_SET(nhp_outerEditPtr, 0))
                    {
                        if (!CTC_IS_BIT_SET(nhp_outerEditPtr, 1))
                        {
                            ds = (uint8*)&l3edit_12w + DRV_TABLE_ENTRY_SIZE(lchip, DsL3Edit3W_t);
                        }
                        else
                        {
                            ds = (uint8*)&l3edit_12w + 3 * DRV_TABLE_ENTRY_SIZE(lchip, DsL3Edit3W_t);
                        }
                        l2edit_l2RewriteType = GetDsL2Edit3W(V, l2EditType_f, ds);
                    }
                    else if (!CTC_IS_BIT_SET(nhp_outerEditPtr, 1))
                    {
                        ds = (uint8*)&l3edit_12w;
                        l2edit_l2RewriteType = GetDsL2Edit6W(V, l2EditType_f, ds);
                    }
                    else
                    {
                        ds = (uint8*)&l3edit_12w + 2 * DRV_TABLE_ENTRY_SIZE(lchip, DsL2Edit3W_t);
                        l2edit_l2RewriteType = GetDsL2Edit6W(V, l2EditType_f, ds);
                    }
                }
                else if (GetDbgEpeEgressEditInfo(V, nhpOuterEditPtrEn_f, &egress_edit_info) &&
                         !nhpOuterEditPtrType && edit_nhpOuterEditLocation)
                {
                    next_edit_ptr = nhp_outerEditPtr;
                    next_edit_type = nhpOuterEditPtrType;
                    next_edit_valid = 1;
                }
                if (nhp_middleEditPtrEn)
                {
                    if (next_edit_valid && !next_edit_type)
                    {
                        outer_edit_ptr_x_valid = 1;
                        outer_edit_ptr_x = next_edit_ptr;
                    }
                    next_edit_ptr = GetDbgEpeEgressEditInfo(V, nhpMiddleEditPtr_f, &egress_edit_info);
                    next_edit_type = 1;
                    next_edit_valid = 1;
                }
            }
            /*outer pipeline1*/
            if (GetDbgEpeEgressEditInfo(V, outerEditPipe2Exist_f, &egress_edit_info) && next_edit_valid)
            {
                cmd = DRV_IOR(DsL3Edit6W3rd_t, DRV_ENTRY_FLAG);
                DRV_IOCTL(lchip, next_edit_ptr >> 1, DRV_CMD_PP_EN(cmd), &l3edit_6w3rd);
                DIAG_INFO_CHAR(pos, "outer-l3edit", STR_ARRAY(l3_edit,GetDsL3Edit6W3rd(V, l3EditType_f, &l3edit_6w3rd)))
                DIAG_INFO_U32_HEX(pos, "edit-table-index", next_edit_ptr)
                DIAG_INFO_CHAR(pos, "edit-table-name", STR_ARRAY(l3_edit_name,GetDsL3Edit6W3rd(V, l3EditType_f, &l3edit_6w3rd)))
                if (!GetDbgEpeEgressEditInfo(V, outerEditPipe2ForL2Edit_f, &egress_edit_info))
                {
                    //next_edit_ptr = next_edit_ptr + (nhp_middleEditPtrEn? );spmeProtectEn useless

                    if (!CTC_IS_BIT_SET(next_edit_ptr, 0) && GetDsL3Edit6W3rd(V, l3EditType_f, &l3edit_6w3rd) == DIAG_L3EDITTYPE_MPLS2X)
                    {
                        if (!GetDsL3Edit6W3rd(V, nextEditPtrValid_f, &l3edit_6w3rd))
                        {
                            next_edit_ptr = 0;
                            next_edit_valid = 0;
                        }
                        else
                        {
                            next_edit_ptr = GetDsL3Edit6W3rd(V, outerEditPtr_f, &l3edit_6w3rd);
                            next_edit_type = GetDsL3Edit6W3rd(V, outerEditPtrType_f, &l3edit_6w3rd);
                            next_edit_valid = 1;
                        }
                    }
                    else
                    {
                        if (!CTC_IS_BIT_SET(next_edit_ptr, 0))
                        {
                            ds = (uint8*)&l3edit_6w3rd;
                        }
                        else
                        {
                            ds = (uint8*)&l3edit_6w3rd + DRV_TABLE_ENTRY_SIZE(lchip, DsL3Edit3W_t);
                        }
                        if (GetDsL3Edit3W3rd(V, nextEditPtrValid_f, ds))
                        {
                            next_edit_ptr = 0;
                            next_edit_valid = 0;
                        }
                        else
                        {
                            next_edit_ptr = GetDsL3Edit3W3rd(V, outerEditPtr_f, ds);
                            next_edit_type = GetDsL3Edit3W3rd(V, outerEditPtrType_f, ds);
                            next_edit_valid = 1;
                        }
                    }
                }
                else
                {
                    cmd = DRV_IOR(DsL3Edit6W3rd_t, DRV_ENTRY_FLAG);
                    DRV_IOCTL(lchip, next_edit_ptr >> 1, DRV_CMD_PP_EN(cmd), &l3edit_6w3rd);
                    next_edit_valid = 0;
                    do_l2_edit = 1;
                    l2_edit_ptr = next_edit_ptr;
                    l2_individual_memory = 1;
                    ds = &l3edit_6w3rd;
                }
            }
            if (nhp_middleEditPtrEn && outer_edit_ptr_x_valid)
            {
                next_edit_ptr = outer_edit_ptr_x;
                next_edit_type = 0;
                next_edit_valid = 1;
            }

            /*outer pipeline2*/
            if (!next_edit_type && next_edit_valid)
            {
                do_l2_edit = 1;
                l2_edit_ptr = next_edit_ptr;
                l2_individual_memory = 1;
                l2edit_is6w = (DIAG_EDITTYPE_TYPE2X == GetDbgEpeEgressEditInfo(V, outerEditPipe3Type_f, &egress_edit_info));
            }
        }
    }
    else if (2 == nhpShareType)/*NHPSHARETYPE_L2EDIT_PLUS_STAG_OP = 2*/
    {
        /*inner edit*/
        value = GetDbgEpeNextHopInfo(V, nhpInnerEditPtr_f, &nexthop_info);
        if (edit_valid
            && GetDbgEpeEgressEditInfo(V, innerEditExist_f, &egress_edit_info))
        {
            if (GetDbgEpeEgressEditInfo(V, nhpInnerEditPtrEn_f, &egress_edit_info) &&
                GetDbgEpeEgressEditInfo(V, innerEditPtrType_f, &egress_edit_info))
            {
                DIAG_INFO_CHAR(pos, "inner-l3edit", STR_ARRAY(l3_edit,l3edit_l3RewriteType))
                if (l3edit_l3RewriteType == DRV_ENUM(DRV_L3EDITTYPE_MPLS1X) ||
                    l3edit_l3RewriteType == DRV_ENUM(DRV_L3EDITTYPE_MPLS2X) ||
                    l3edit_l3RewriteType == DRV_ENUM(DRV_L3EDITTYPE_MPLS4X))
                {
                    cmd = DRV_IOR(DsL3EditAddMpls1X_t, DRV_ENTRY_FLAG);
                    CTC_ERROR_RETURN(DRV_IOCTL(lchip, value, DRV_CMD_PP_EN(cmd), &l3edit_mpls1X));
                    label = GetDsL3EditAddMpls1X(V, label_f, &l3edit_mpls1X);
                    DIAG_INFO_UINT32(pos, "new-label", label)
                }
                DIAG_INFO_UINT32(pos, "edit-table-index", value)
                DIAG_INFO_CHAR(pos, "edit-table-name",STR_ARRAY(l3_edit_name,l3edit_l3RewriteType))
            }
            else if (GetDbgEpeEgressEditInfo(V, nhpInnerEditPtrEn_f, &egress_edit_info) &&
                     !GetDbgEpeEgressEditInfo(V, innerEditPtrType_f, &egress_edit_info))
            {
                DIAG_INFO_CHAR(pos, "inner-l2edit", STR_ARRAY(l2_edit,l2edit_l2RewriteType))
                DIAG_INFO_UINT32(pos, "edit-table-index", value)
                DIAG_INFO_CHAR(pos, "edit-table-name", STR_ARRAY(l2_edit_name,l2edit_l2RewriteType))
            }
        }

        if (l2edit_l2RewriteType)/* l2edit */
        {
            do_l2_edit = 1;
            l2_edit_ptr = nhp_outerEditPtr;
            l2_individual_memory = edit_nhpOuterEditLocation? 1 : 0;
        }
    }

    DIAG_INFO_NONE(pos, "Layer2 Packet Editing")
    if (GetDbgEpePldProcInfo(V, valid_f, &payload_info))
    {
        value = GetDbgEpePldProcInfo(V, svlanTagOperation_f, &payload_info);
        value1 = GetDbgEpePldProcInfo(V, cvlanTagOperation_f, &payload_info);
        vlan_edit_valid =   (value == DIAG_VLAN_ACTION_DELETE)  && GetDbgEpePldProcInfo(V, outputSvlanIdValid_f, &payload_info)     &&
                            (value1 == DIAG_VLAN_ACTION_ADD)    && !GetDbgEpePldProcInfo(V, outputCvlanIdValid_f, &payload_info);
        value = vlan_edit_valid? DIAG_VLAN_ACTION_ADD : value;
        if (value || value1)
        {
            if (value)
            {
                DIAG_INFO_CHAR(pos, "svlan-edit", STR_ARRAY(sys_diag_vlan_action,value))
                if ((DIAG_VLAN_ACTION_MODIFY == value) || (DIAG_VLAN_ACTION_ADD== value))
                {
                    value = GetDbgEpePldProcInfo(V, l2NewSvlanTag_f, &payload_info);
                    DIAG_INFO_UINT32(pos, "new-cos", (value >> 13) & 0x7)
                    DIAG_INFO_UINT32(pos, "new-cfi", (value >> 12) & 0x1)
                    DIAG_INFO_UINT32(pos, "new-vlan-id", value & 0xFFF)
                }
            }
            if (value1)
            {
                DIAG_INFO_CHAR(pos, "cvlan-edit", STR_ARRAY(sys_diag_vlan_action,value1))
                if ((DIAG_VLAN_ACTION_MODIFY == value1) || (DIAG_VLAN_ACTION_ADD== value1))
                {
                    value1 = GetDbgEpePldProcInfo(V, l2NewCvlanTag_f, &payload_info);
                    DIAG_INFO_UINT32(pos, "new-cos", (value1 >> 13) & 0x7)
                    DIAG_INFO_UINT32(pos, "new-cfi", (value1 >> 12) & 0x1)
                    DIAG_INFO_UINT32(pos, "new-vlan-id", value1 & 0xFFF)
                }
            }
        }
    }
    if (DIAG_PLD_OP_ROUTE_COMPACT == GetDbgEpeNextHopInfo(V, payloadOperation_f, &nexthop_info) ||
        (DIAG_PLD_OP_NONE == GetDbgEpeNextHopInfo(V, payloadOperation_f, &nexthop_info) &&
         GetDbgEpeNextHopInfo(V, routeNoL2Edit_f, &nexthop_info)))
    {
        uint32 dest_map = 0;
        cmd = DRV_IOR(met_info1_tbl[pp_id%PP_NUM_PER_CORE],  DbgFwdMetFifoInfo1_destMap_f);
        CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &dest_map));
        if (!CTC_IS_BIT_SET(dest_map,18))
        {
            GetDsNextHop4W(A, macDa_f, &nexthop_4w, hw_mac);
            DIAG_INFO_CHAR(pos, "mac-edit", "ENABLE")
            DIAG_INFO_MAC(pos, "new-macda", hw_mac)
        }
    }
    /*NHPSHARETYPE_L2EDIT_PLUS_L3EDIT_OP=0*/
    if ((0 == nhpShareType) || (nhp_nhpIs8w))
    {
        /*inner edit*/
        value = GetDbgEpeNextHopInfo(V, nhpInnerEditPtr_f, &nexthop_info);
        if (edit_valid
            && GetDbgEpeEgressEditInfo(V, innerEditExist_f, &egress_edit_info)
            && !GetDbgEpeEgressEditInfo(V, innerEditPtrType_f, &egress_edit_info))/* inner for l2edit */
        {
            if (value)
            {
                value1 = GetDbgEpeEgressEditInfo(V, innerL2EditType_f, &egress_edit_info);
                DIAG_INFO_CHAR(pos, "inner-mac-edit", STR_ARRAY(l2_edit,value1))
                DIAG_INFO_UINT32(pos, "edit-table-index", value)
                DIAG_INFO_CHAR(pos, "edit-table-name", STR_ARRAY(l2_edit_name,value1))
            }
            else if (l2edit_l2RewriteType)
            {
                do_l2_edit = 1;
                l2_edit_ptr = value;
                l2_individual_memory = 0;
            }
        }
    }
    if (do_l2_edit)
    {
        DIAG_INFO_CHAR(pos, "l2edit", STR_ARRAY(l2_edit,l2edit_l2RewriteType))
        DIAG_INFO_UINT32(pos, "edit-table-index", l2_edit_ptr)
        if (l2edit_is6w && l2_individual_memory)
        {
            DIAG_INFO_CHAR(pos, "edit-table-name", "DsL2Edit6WOuter")
        }
        else if (l2_individual_memory)
        {
            DIAG_INFO_CHAR(pos, "edit-table-name", "DsL2Edit3WOuter")
            cmd = DRV_IOR(DsL2Edit6WOuter_t, DRV_ENTRY_FLAG);
            DRV_IOCTL(lchip, l2_edit_ptr >> 1, DRV_CMD_PP_EN(cmd), &l2edit_6w_outer);
            if (CTC_IS_BIT_SET(l2_edit_ptr, 0))
            {
                ds = (uint8*)&l2edit_6w_outer + DRV_TABLE_ENTRY_SIZE(lchip, DsL2Edit3WOuter_t);
            }
            else
            {
                ds = (uint8*)&l2edit_6w_outer;
            }
            if (GetDsL2EditAddEth1X(V, macDaEn_f, ds))
            {
                GetDsL2EditAddEth1X(A, macDa_f, ds, hw_mac);
                DIAG_INFO_MAC(pos, "New-Mac", hw_mac)
            }
        }
        else
        {
            DIAG_INFO_CHAR(pos, "edit-table-name", STR_ARRAY(l2_edit_name,l2edit_l2RewriteType))
            cmd = DRV_IOR(DsL2EditRwEth2X_t, DRV_ENTRY_FLAG);
            DRV_IOCTL(lchip, l2_edit_ptr, DRV_CMD_PP_EN(cmd), &l2edit_6w_outer);
            if ((l2edit_l2RewriteType == DIAG_L2EDIT_TYPE_RWETH2X) &&
                (GetDsL2EditRwEth2X(V, macSaRewriteEn_f, &l2edit_6w_outer) && GetDsL2EditRwEth2X(V, macSaCopyDst_f, &l2edit_6w_outer) &&
                 GetDsL2EditRwEth2X(V, macDaRewriteEn_f, &l2edit_6w_outer) && GetDsL2EditRwEth2X(V, macDaCopySrc_f, &l2edit_6w_outer)))
            {
                DIAG_INFO_CHAR(pos, "Mac-Swap", DIAG_ENABLE);
            }
        }
    }

    return CTC_E_NONE;
}

STATIC int32
_sys_at_diag_pkt_trace_get_epe_hdr_edit_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint32 value = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_EPE;
    DbgEpeHdrEditInfo_m edit_info;
    MsEpeHdrEditToQMgr_m epe2qmgr_info;
    char* str_type[] = {"IPv4", "IPv6", "MPLS", "TRILL"};
    char* sys_diag_int_op[] = {"", "SOURCE", "TRANSIT", "SINK"};
    char *sys_diag_vlan_action[] = {"None", "Add", "Delete", "Replace"};

    sal_memset(&edit_info, 0, sizeof(DbgEpeHdrEditInfo_m));
    cmd = DRV_IOR(DbgEpeHdrEditInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &edit_info));
    if (!GetDbgEpeHdrEditInfo(V, valid_f, &edit_info))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_EPE;
    DIAG_INFO_NONE(pos, "EPE Header Editing")

    value = GetDbgEpeHdrEditInfo(V, cfHeaderLen_f, &edit_info);
    if (value)
    {
        DIAG_INFO_UINT32(pos, "stacking-header-length", value)
    }
    value = GetDbgEpeHdrEditInfo(V, l2NewHeaderLen_f, &edit_info);
    if (value)
    {
        DIAG_INFO_UINT32(pos, "new-l2-header-length", value)
    }
    value = GetDbgEpeHdrEditInfo(V, l2NewHeaderOuterLen_f, &edit_info);
    if (value)
    {
        DIAG_INFO_UINT32(pos, "new-l2-outer-header-length", value)
    }
    value = GetDbgEpeHdrEditInfo(V, l3NewHeaderLen_f, &edit_info);
    if (value)
    {
        DIAG_INFO_UINT32(pos, "new-l3-header-length", value)
    }
    value = GetDbgEpeHdrEditInfo(V, l3NewHeaderOuterLen_f, &edit_info);
    if (value)
    {
        DIAG_INFO_UINT32(pos, "new-l3-outer-header-length", value)
    }

    DIAG_INFO_UINT32(pos, "local-src-port", GetDbgEpeHdrEditInfo(V, srcLocalPhyPort_f, &edit_info))
    DIAG_INFO_UINT32(pos, "local-dst-port", GetDbgEpeHdrEditInfo(V, destLocalPhyPort_f, &edit_info))

    if (GetDbgEpeHdrEditInfo(V, loopbackEn_f, &edit_info))
    {
        DIAG_INFO_CHAR(pos, "loopback", "ENABLE")
    }
    if (GetDbgEpeHdrEditInfo(V, isSpanPkt_f, &edit_info) && GetDbgEpeHdrEditInfo(V, egressExceptionVectorValid_f, &edit_info))
    {
        DIAG_INFO_CHAR(pos, "is-span-packet", "TRUE")
    }
    else if (GetDbgEpeHdrEditInfo(V, egressExceptionVectorValid_f, &edit_info))
    {
        DIAG_INFO_CHAR(pos, "to-cpu", "TRUE")
    }
    if (GetDbgEpeHdrEditInfo(V, isAdvancedMacsec_f, &edit_info))
    {
        DIAG_INFO_CHAR(pos, "is-adv-mac-sec", "TRUE")
    }
    if (GetDbgEpeHdrEditInfo(V, isCloudSec_f, &edit_info))
    {
        DIAG_INFO_CHAR(pos, "is-cloud-sec", "TRUE")
    }
    if (GetDbgEpeHdrEditInfo(V, newTtlValid_f, &edit_info))
    {
        DIAG_INFO_CHAR(pos, "new-ttl-packet-type", STR_ARRAY(str_type,GetDbgEpeHdrEditInfo(V, newTtlPacketType_f, &edit_info)))
    }

    value = GetDbgEpeHdrEditInfo(V, aclCvlanTagOperation_f, &edit_info) << 16;
    value = value | GetDbgEpeHdrEditInfo(V, aclSvlanTagOperation_f, &edit_info);
    if (value)
    {
        DIAG_INFO_CHAR(pos, "acl-edit-stag", STR_ARRAY(sys_diag_vlan_action,(value & 0xFFFF)))
        DIAG_INFO_CHAR(pos, "acl-edit-ctag", STR_ARRAY(sys_diag_vlan_action,(value >> 16)))
    }

    if (GetDbgEpeHdrEditInfo(V, sourceChannelLinkAggregateEn_f, &edit_info))
    {
        DIAG_INFO_UINT32(pos, "src-chan-agg-id", GetDbgEpeHdrEditInfo(V, sourceChannelLinkAggregate_f, &edit_info))
    }
    if (GetDbgEpeHdrEditInfo(V, destChannelLinkAggregateEn_f, &edit_info))
    {
        DIAG_INFO_UINT32(pos, "dst-chan-agg-id", GetDbgEpeHdrEditInfo(V, destChannelLinkAggregate_f, &edit_info))
    }

    value = GetDbgEpeHdrEditInfo(V, intOpType_f, &edit_info);
    if (value)
    {
        DIAG_INFO_CHAR(pos, "int-op-type", STR_ARRAY(sys_diag_int_op,value))
        DIAG_INFO_U32_HEX(pos, "int-op-ptr", GetDbgEpeHdrEditInfo(V, intOpPtr_f, &edit_info))
    }

    if (GetDbgEpeHdrEditInfo(V, vlanEncodeEn_f, &edit_info) && GetDbgEpeHdrEditInfo(V, voltIdEn_f, &edit_info)) /*Mux vlan*/
    {
        DIAG_INFO_UINT32(pos, "volt-id-en", GetDbgEpeHdrEditInfo(V, vlanEncodeType_f, &edit_info))
    }
    else if (GetDbgEpeHdrEditInfo(V, vlanEncodeEn_f, &edit_info))
    {
        DIAG_INFO_UINT32(pos, "vlan-encode-type", GetDbgEpeHdrEditInfo(V, vlanEncodeType_f, &edit_info)) /*Mux vlan*/
    }

    GetDbgEpeHdrEditInfo(A, msEpeHdrEditToQMgr_f, &edit_info, &epe2qmgr_info);
    DIAG_INFO_UINT32(pos, "to-qmgr-chan-id", GetMsEpeHdrEditToQMgr(V, channelId_f, &epe2qmgr_info))
    DIAG_INFO_CHAR(pos, "to-qmgr-buffer-type", GetMsEpeHdrEditToQMgr(V, bufSel_f, &epe2qmgr_info) ? "MC" : "UC" )
    DIAG_INFO_UINT32(pos, "to-qmgr-queue-offset", GetMsEpeHdrEditToQMgr(V, queSel_f, &epe2qmgr_info))

    /* Drop Process */
    _sys_at_diag_pkt_tracce_drop_map(lchip,p_rslt,
                                          GetDbgEpeHdrEditInfo(V, discard_f, &edit_info),
                                          GetDbgEpeHdrEditInfo(V, discardType_f,  &edit_info));
    /* Exception Process */
    _sys_at_diag_pkt_tracce_exception_map(lchip,p_rslt,
                                               GetDbgEpeHdrEditInfo(V, exceptionEn_f, &edit_info),
                                               GetDbgEpeHdrEditInfo(V, exceptionIndex_f, &edit_info),
                                               GetDbgEpeHdrEditInfo(V, exceptionSubIndex_f, &edit_info));
    return CTC_E_NONE;
}

STATIC int32
_sys_at_diag_pkt_trace_get_tm_bs_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint32 value = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_TM;
    uint8 dp_id = 0;
    DbgFwdBufStoreInfo_m buf_store_info;
    MsIpeToBsr_m ipetobsr;
    DbgIpfixMmuAccInfo_m ipfixMmuAccInfo;
    DbgMmuErmInfoMc1_m mmuErmInfoMc1;
    DbgMmuErmInfoMc0_m mmuErmInfoMc0;
    DbgMmuErmInfoUc_m mmuErmInfoUc;
    DbgMmuIrmInfoMc_m mmuIrmInfoMc;
    DbgMmuIrmInfoUc_m MmuIrmInfoUc;

    char* port_type[] = {"NETWORK", "CPU", "OAM", "DMA", "LOOP", "ELOG", "DMAEVENT", "RESERVED"};
    char* fwd_type[] = {"NONE", "RESERVED0", "IPUC", "IPMC", "L2UC", "L2MC", "BC", "UNKNOWNL2", "MPLS", "VPLS",
                            "L3VPN", "VPWS", "TRILL_UC", "TRILL_MC", "FCOE", "MPLS_OTHER_VPN"};

    p_rslt->position = CTC_DIAG_TRACE_POS_TM;
    DIAG_INFO_NONE(pos, "BufferStore")

    for (dp_id = 0; dp_id < MCHIP_CAP(SYS_CAP_DP_MAX_NUM); dp_id++)
    {
        cmd = DRV_IOR(DbgFwdBufStoreInfo_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_DP_EN(cmd, dp_id), &buf_store_info));

        if (!GetDbgFwdBufStoreInfo(V, valid_f, &buf_store_info))
        {
            continue;
        }

        DIAG_INFO_UINT32(pos,"DP-ID:",dp_id)
        value = GetDbgFwdBufStoreInfo(V, ppDestPortValid_f, &buf_store_info);
        if (value)
        {
            DIAG_INFO_UINT32(pos, "dest-ppport", GetDbgFwdBufStoreInfo(V, ppDestPort_f, &buf_store_info))
        }
        value = GetDbgFwdBufStoreInfo(V, dstPortType_f, &buf_store_info);
        DIAG_INFO_CHAR(pos, "dst-port-type",STR_ARRAY(port_type,value))
        value = GetDbgFwdBufStoreInfo(V, srcPortType_f, &buf_store_info);
        DIAG_INFO_CHAR(pos, "src-port-type", STR_ARRAY(port_type,value))
        DIAG_INFO_UINT32(pos, "resrc-use-cnt", GetDbgFwdBufStoreInfo(V, resrcUseCnt_f, &buf_store_info))
        if (GetDbgFwdBufStoreInfo(V, isSpanPkt_f, &buf_store_info))
        {
            DIAG_INFO_UINT32(pos, "is-span-pkt", GetDbgFwdBufStoreInfo(V, isSpanPkt_f, &buf_store_info))
        }

        if (GetDbgFwdBufStoreInfo(V, isToCpuExcp_f, &buf_store_info))
        {
            DIAG_INFO_UINT32(pos, "is-toCPU-excp", 1)
        }
        if (GetDbgFwdBufStoreInfo(V, spanOnDropExcp_f, &buf_store_info))
        {
            DIAG_INFO_UINT32(pos, "spanOnDrop-excp", 1)
        }
        DIAG_INFO_CHAR(pos, "IRM-UC-resource-chk", GetDbgFwdBufStoreInfo(V, resourceCheckPassUc_f, &buf_store_info) & 0x1 ? "PASS" : "FAIL")
        DIAG_INFO_CHAR(pos, "IRM-MC-resource-chk", GetDbgFwdBufStoreInfo(V, resourceCheckPassMc_f, &buf_store_info) & 0x1 ? "PASS" : "FAIL")
        DIAG_INFO_CHAR(pos, "ERM-UC-resource-chk", GetDbgFwdBufStoreInfo(V, resourceCheckPassUc_f, &buf_store_info) & 0x2 ? "PASS" : "FAIL")
        DIAG_INFO_CHAR(pos, "ERM-MC-resource-chk", GetDbgFwdBufStoreInfo(V, resourceCheckPassMc_f, &buf_store_info) & 0x2 ? "PASS" : "FAIL")
        if (GetDbgFwdBufStoreInfo(V, fwdCheckDiscard_f, &buf_store_info))
        {
            DIAG_INFO_CHAR(pos, "drop-desc", "fwd-chk-discard")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        GetDbgFwdBufStoreInfo(A, ipeToBsr_f, &buf_store_info, &ipetobsr);
        value = GetMsIpeToBsr(V, mc_exceptionVector_f, &ipetobsr);
        if (value & (1 << CTC_DIAG_EXCP_VEC_EXCEPTION))
        {
            DIAG_INFO_U32_HEX(pos, "exception-vector", value)
            p_rslt->dest_type = CTC_DIAG_DEST_CPU;
            p_rslt->excp_vector = value;
            p_rslt->flags |= CTC_DIAG_TRACE_RSTL_FLAG_EXCP_VECTOR;
        }
        if (GetMsIpeToBsr(V, mc_isEgressException_f, &ipetobsr))
        {
            DIAG_INFO_CHAR(pos, "egress-exception", "TRUE")
        }
        value = GetMsIpeToBsr(V, pktForwardingType_f, &ipetobsr);
        DIAG_INFO_CHAR(pos, "fwd-type", STR_ARRAY(fwd_type,value))
        if (GetMsIpeToBsr(V, ppDestPortValid_f, &ipetobsr))
        {
            DIAG_INFO_UINT32(pos, "uc-queue-offset", GetMsIpeToBsr(V, uc_queueOffset_f, &ipetobsr))
            DIAG_INFO_UINT32(pos, "uc-dst-channel", GetMsIpeToBsr(V, uc_destChannelId_f, &ipetobsr))
        }
        if (GetMsIpeToBsr(V, uc_destIdDiscard_f, &ipetobsr))
        {
            DIAG_INFO_CHAR(pos, "drop-desc", "uc-destid-discard")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if (GetMsIpeToBsr(V, srcGuaranteeEn_f, &ipetobsr))
        {
            DIAG_INFO_UINT32(pos, "src-guaranteeEn", 1)
        }
        DIAG_INFO_UINT32(pos, "mapped-tc", GetMsIpeToBsr(V, erm_mappedTc_f, &ipetobsr))
        DIAG_INFO_UINT32(pos, "mapped-sc", GetMsIpeToBsr(V, erm_mappedSc_f, &ipetobsr))
        if (GetMsIpeToBsr(V, erm_isCriticalPacket_f, &ipetobsr))
        {
            DIAG_INFO_UINT32(pos, "is-critical-pkt", 1)
        }
        if (GetMsIpeToBsr(V, erm_isC2cPacket_f, &ipetobsr))
        {
            DIAG_INFO_UINT32(pos, "is-c2c-pkt", 1)
        }

        if (GetDbgFwdBufStoreInfo(V, fwdCheckDiscard_f, &buf_store_info))
        {
            DIAG_INFO_CHAR(pos, "drop-desc", "forward-check-fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }

#if (SDK_WORK_PLATFORM == 0)
        if (!GetDbgFwdBufStoreInfo(V, resourceCheckPassUc_f, &buf_store_info))
        {
            DIAG_INFO_CHAR(pos, "drop-desc-uc", "resource-check-fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if (!GetDbgFwdBufStoreInfo(V, resourceCheckPassMc_f, &buf_store_info))
        {
            DIAG_INFO_CHAR(pos, "drop-desc-mc", "resource-check-fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
#endif
    }


    cmd = DRV_IOR(DbgIpfixMmuAccInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_DUMP(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &ipfixMmuAccInfo));
    if (GetDbgIpfixMmuAccInfo(V, valid_f, &ipfixMmuAccInfo))
    {
        DIAG_INFO_NONE(pos, "Mmu Ipfix Process")
        value =  GetDbgIpfixMmuAccInfo(V, isUpdateOperation_f, &ipfixMmuAccInfo);
        DIAG_INFO_CHAR(pos, "opration-update", value ? "TRUE" : "FALSE")
        if (GetDbgIpfixMmuAccInfo(V, flowIdValid_f, &ipfixMmuAccInfo))
        {
            DIAG_INFO_UINT32(pos, "key-index", GetDbgIpfixMmuAccInfo(V, flowId_f, &ipfixMmuAccInfo))
        }
        DIAG_INFO_UINT32(pos, "igs-flow-change-cnt", GetDbgIpfixMmuAccInfo(V, flowChangeCnt_f, &ipfixMmuAccInfo))
        DIAG_INFO_UINT32(pos, "mmu-flow-change-cnt", GetDbgIpfixMmuAccInfo(V, mmuFlowChangeCnt_f, &ipfixMmuAccInfo))
        DIAG_INFO_UINT32(pos, "cfg-profile-id", GetDbgIpfixMmuAccInfo(V, ipfixCfgProfileId_f, &ipfixMmuAccInfo))
    }

    cmd = DRV_IOR(DbgMmuErmInfoMc1_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &mmuErmInfoMc1));
    if(GetDbgMmuErmInfoMc1(V,valid_f,&mmuErmInfoMc1))
    {
        DIAG_INFO_NONE(pos, "Mmu Erm Mc1")

        if(!GetDbgMmuErmInfoMc1(V,spanOnDropPass_f,&mmuErmInfoMc1))
        {
             DIAG_INFO_CHAR(pos, "span On Drop ", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        DIAG_INFO_UINT32(pos, "mapped-tc", GetDbgMmuErmInfoMc1(V, mappedTc_f, &mmuErmInfoMc1))
        DIAG_INFO_UINT32(pos, "mapped-sc", GetDbgMmuErmInfoMc1(V, mappedSc_f, &mmuErmInfoMc1))
        if (!GetDbgMmuErmInfoMc1(V, resourceCheckPass_f, &mmuErmInfoMc1))
        {
            DIAG_INFO_CHAR(pos, "drop-desc-mc", "resource-check-fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(!GetDbgMmuErmInfoMc1(V,queueThrdPass_f,&mmuErmInfoMc1))
        {
            DIAG_INFO_CHAR(pos, "queue Thrd", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(!GetDbgMmuErmInfoMc1(V,portScThrdPass_f,&mmuErmInfoMc1))
        {
            DIAG_INFO_CHAR(pos, "port Sc Thrd", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(!GetDbgMmuErmInfoMc1(V,portThrdPass_f,&mmuErmInfoMc1))
        {
            DIAG_INFO_CHAR(pos, "port Thrd", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(!GetDbgMmuErmInfoMc1(V,scThrdPass_f,&mmuErmInfoMc1))
        {
            DIAG_INFO_CHAR(pos, "sc Thrd Pass", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(!GetDbgMmuErmInfoMc1(V,totalThrdPass_f,&mmuErmInfoMc1))
        {
            DIAG_INFO_CHAR(pos, "total Thrd", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(GetDbgMmuErmInfoMc1(V,isC2cPacket_f,&mmuErmInfoMc1)&&!GetDbgMmuErmInfoMc1(V,c2cPass_f,&mmuErmInfoMc1))
        {
            DIAG_INFO_CHAR(pos, "c2c", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(GetDbgMmuErmInfoMc1(V,isCriticalPacket_f,&mmuErmInfoMc1)&&!GetDbgMmuErmInfoMc1(V,criticalPass_f,&mmuErmInfoMc1))
        {
            DIAG_INFO_CHAR(pos, "critical", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
    }

    cmd = DRV_IOR(DbgMmuErmInfoMc0_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &mmuErmInfoMc0));
    if(GetDbgMmuErmInfoMc0(V,valid_f,&mmuErmInfoMc0))
    {
        DIAG_INFO_NONE(pos, "Mmu Erm Mc0")

        if(!GetDbgMmuErmInfoMc0(V,spanOnDropPass_f,&mmuErmInfoMc0))
        {
            DIAG_INFO_CHAR(pos, "span On Drop ", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        DIAG_INFO_UINT32(pos, "mapped-tc", GetDbgMmuErmInfoMc0(V, mappedTc_f, &mmuErmInfoMc0))
        DIAG_INFO_UINT32(pos, "mapped-sc", GetDbgMmuErmInfoMc0(V, mappedSc_f, &mmuErmInfoMc0))
        if (!GetDbgMmuErmInfoMc0(V, resourceCheckPass_f, &mmuErmInfoMc0))
        {
            DIAG_INFO_CHAR(pos, "drop-desc-mc", "resource-check-fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(!GetDbgMmuErmInfoMc0(V,queueThrdPass_f,&mmuErmInfoMc0))
        {
            DIAG_INFO_CHAR(pos, "queue Thrd", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(!GetDbgMmuErmInfoMc0(V,portScThrdPass_f,&mmuErmInfoMc0))
        {
            DIAG_INFO_CHAR(pos, "port Sc Thrd", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(!GetDbgMmuErmInfoMc0(V,portThrdPass_f,&mmuErmInfoMc0))
        {
            DIAG_INFO_CHAR(pos, "port Thrd", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(!GetDbgMmuErmInfoMc0(V,scThrdPass_f,&mmuErmInfoMc0))
        {
            DIAG_INFO_CHAR(pos, "sc Thrd Pass", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(!GetDbgMmuErmInfoMc0(V,totalThrdPass_f,&mmuErmInfoMc0))
        {
            DIAG_INFO_CHAR(pos, "total Thrd", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(GetDbgMmuErmInfoMc0(V,isC2cPacket_f,&mmuErmInfoMc0)&&!GetDbgMmuErmInfoMc0(V,c2cPass_f,&mmuErmInfoMc0))
        {
            DIAG_INFO_CHAR(pos, "c2c", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(GetDbgMmuErmInfoMc0(V,isCriticalPacket_f,&mmuErmInfoMc0)&&!GetDbgMmuErmInfoMc0(V,criticalPass_f,&mmuErmInfoMc0))
        {
            DIAG_INFO_CHAR(pos, "critical", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
    }

    for (dp_id = 0; dp_id < MCHIP_CAP(SYS_CAP_DP_MAX_NUM); dp_id++)
    {
        cmd = DRV_IOR(DbgMmuErmInfoUc_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_DP_EN(cmd,dp_id), &mmuErmInfoUc));

        if(!GetDbgMmuErmInfoUc(V,valid_f,&mmuErmInfoUc))
        {
            continue;
        }

        DIAG_INFO_NONE(pos, "Mmu Erm Uc")
        DIAG_INFO_UINT32(pos,"DP-ID:",dp_id)
        DIAG_INFO_UINT32(pos, "mapped-tc", GetDbgMmuErmInfoUc(V, mappedTc_f, &mmuErmInfoUc))
        DIAG_INFO_UINT32(pos, "mapped-sc", GetDbgMmuErmInfoUc(V, mappedSc_f, &mmuErmInfoUc))
        DIAG_INFO_UINT32(pos, "port microburst valid", GetDbgMmuErmInfoUc(V, microburstValid_f, &mmuErmInfoUc)&0x01)
        DIAG_INFO_UINT32(pos, "portTc microburst valid", GetDbgMmuErmInfoUc(V, microburstValid_f, &mmuErmInfoUc)&0x02)
        if (!GetDbgMmuErmInfoUc(V, resourceCheckPass_f, &mmuErmInfoUc))
        {
            DIAG_INFO_CHAR(pos, "drop-desc-uc", "resource-check-fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(!GetDbgMmuErmInfoUc(V,queueThrdPass_f,&mmuErmInfoUc))
        {
            DIAG_INFO_CHAR(pos, "queue Thrd", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(!GetDbgMmuErmInfoUc(V,portThrdPass_f,&mmuErmInfoUc))
        {
            DIAG_INFO_CHAR(pos, "port Thrd", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(!GetDbgMmuErmInfoUc(V,portScThrdPass_f,&mmuErmInfoUc))
        {
            DIAG_INFO_CHAR(pos, "portSc Thrd", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(!GetDbgMmuErmInfoUc(V,scThrdPass_f,&mmuErmInfoUc))
        {
            DIAG_INFO_CHAR(pos, "sc Thrd", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(!GetDbgMmuErmInfoUc(V,totalThrdPass_f,&mmuErmInfoUc))
        {
            DIAG_INFO_CHAR(pos, "total Thrd", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(GetDbgMmuErmInfoUc(V,isC2cPacket_f,&mmuErmInfoUc)&&!GetDbgMmuErmInfoUc(V,c2cPass_f,&mmuErmInfoUc))
        {
            DIAG_INFO_CHAR(pos, "c2c", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(GetDbgMmuErmInfoUc(V,isCriticalPacket_f,&mmuErmInfoUc)&&!GetDbgMmuErmInfoUc(V,criticalPass_f,&mmuErmInfoUc))
        {
            DIAG_INFO_CHAR(pos, "critical", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }

    }

    for (dp_id = 0; dp_id < MCHIP_CAP(SYS_CAP_DP_MAX_NUM); dp_id++)
    {
        cmd = DRV_IOR(DbgMmuIrmInfoMc_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_DP_EN(cmd,dp_id), &mmuIrmInfoMc));

        if(!GetDbgMmuIrmInfoMc(V,valid_f,&mmuIrmInfoMc))
        {
            continue;
        }

        DIAG_INFO_NONE(pos, "Mmu Irm Mc")
        DIAG_INFO_UINT32(pos,"DP-ID:",dp_id)
        if(!GetDbgMmuIrmInfoMc(V,portScThrdPass_f,&mmuIrmInfoMc))
        {
            DIAG_INFO_CHAR(pos, "port ScThrd", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(!GetDbgMmuIrmInfoMc(V,portTcThrdPass_f,&mmuIrmInfoMc))
        {
            DIAG_INFO_CHAR(pos, "port TcThrd", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(!GetDbgMmuIrmInfoMc(V,portThrdPass_f,&mmuIrmInfoMc))
        {
            DIAG_INFO_CHAR(pos, "port Thrd", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(!GetDbgMmuIrmInfoMc(V,scThrdPass_f,&mmuIrmInfoMc))
        {
            DIAG_INFO_CHAR(pos, "sc Thrd Pass", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(!GetDbgMmuIrmInfoMc(V,totalThrdPass_f,&mmuIrmInfoMc))
        {
            DIAG_INFO_CHAR(pos, "total Thrd", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(GetDbgMmuIrmInfoMc(V,isC2cPacket_f,&mmuIrmInfoMc)&&!GetDbgMmuIrmInfoMc(V,c2cPass_f,&mmuIrmInfoMc))
        {
            DIAG_INFO_CHAR(pos, "c2c", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(GetDbgMmuIrmInfoMc(V,isCriticalPacket_f,&mmuIrmInfoMc)&&!GetDbgMmuIrmInfoMc(V,criticalPass_f,&mmuIrmInfoMc))
        {
            DIAG_INFO_CHAR(pos, "critical", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
    }

    for (dp_id = 0; dp_id < MCHIP_CAP(SYS_CAP_DP_MAX_NUM); dp_id++)
    {
        cmd = DRV_IOR(DbgMmuIrmInfoUc_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_DP_EN(cmd,dp_id), &MmuIrmInfoUc));
        if(!GetDbgMmuIrmInfoUc(V,valid_f,&MmuIrmInfoUc))
        {
            continue;
        }
        DIAG_INFO_NONE(pos, "Mmu Irm Uc")
        DIAG_INFO_UINT32(pos,"DP-ID:",dp_id)
        if (!GetDbgMmuIrmInfoUc(V, headroomThrdPass_f, &MmuIrmInfoUc))
        {
            DIAG_INFO_CHAR(pos, "headroomThrd", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(!GetDbgMmuIrmInfoUc(V,portScThrdPass_f,&MmuIrmInfoUc))
        {
            DIAG_INFO_CHAR(pos, "port Sc Thrd", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(!GetDbgMmuIrmInfoUc(V,portTcThrdPass_f,&MmuIrmInfoUc))
        {
            DIAG_INFO_CHAR(pos, "port Tc Thrd", "fail")
             p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(!GetDbgMmuIrmInfoUc(V,portThrdPass_f,&MmuIrmInfoUc))
        {
            DIAG_INFO_CHAR(pos, "port Thrd", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(!GetDbgMmuIrmInfoUc(V,scThrdPass_f,&MmuIrmInfoUc))
        {
            DIAG_INFO_CHAR(pos, "sc Thrd Pass", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(!GetDbgMmuIrmInfoUc(V,totalThrdPass_f,&MmuIrmInfoUc))
        {
            DIAG_INFO_CHAR(pos, "total Thrd", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(GetDbgMmuIrmInfoUc(V,isC2cPacket_f,&MmuIrmInfoUc)&&!GetDbgMmuIrmInfoUc(V,c2cPass_f,&MmuIrmInfoUc))
        {
            DIAG_INFO_CHAR(pos, "c2c", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        if(GetDbgMmuIrmInfoUc(V,isCriticalPacket_f,&MmuIrmInfoUc)&&!GetDbgMmuIrmInfoUc(V,criticalPass_f,&MmuIrmInfoUc))
        {
            DIAG_INFO_CHAR(pos, "critical", "fail")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
    }
    return CTC_E_NONE;
}
STATIC int32
_sys_at_diag_pkt_trace_get_tm_met_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint32 count = 0;
    uint32 value = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_TM;
    char str[64] = {0};
    uint32 ucastId = 0;
    uint32 local_chip = 0;
    uint32 nextMetEntryPtr = 0;
    uint32 metEntryPtr = 0;
    uint32 dest_map = 0;
    uint8 pp_id = lchip - SYS_PP_BASE(lchip);
    uint32 met_info1_tbl[4] = {DbgFwdMetFifoInfo10_t,DbgFwdMetFifoInfo11_t,DbgFwdMetFifoInfo12_t,DbgFwdMetFifoInfo13_t};
    DsMetVector1X_m ds_met1x;
    DsMetVector2X_m ds_met2x;
    DsMetVector4X_m ds_met4x;
    DbgFwdMetFifoInfo1_m met_fifo_info1;
    DbgFwdMetFifoInfo2_m met_fifo_info2;
    MetFifoCtl_m MetFifoCtl;
    char* MetEntryType[]={"DsMetEntry1X","DsMetVector1X","DsMetVector2X","DsMetVector4X"};
    uint32 port_bitmap[16] = {0};
    uint32 entry_num = 0;
    uint8 metType = 0;
    uint8 xmetptr_en = 0;
    uint8 xmetptr_en1 = 0;
    uint8 end_local_re=0;
    uint32 port_bitmap_base = 0;

    sal_memset(&ds_met1x, 0, sizeof(ds_met1x));
    sal_memset(&ds_met2x, 0, sizeof(ds_met2x));
    sal_memset(&ds_met4x, 0, sizeof(ds_met4x));
    cmd = DRV_IOR(met_info1_tbl[pp_id%4], DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &met_fifo_info1));
    cmd = DRV_IOR(DbgFwdMetFifoInfo2_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0,DRV_CMD_PP_EN(cmd), &met_fifo_info2));

    if (!GetDbgFwdMetFifoInfo1(V, valid_f, &met_fifo_info1))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_TM;
    DIAG_INFO_NONE(pos, "MetFifo")

    dest_map = GetDbgFwdMetFifoInfo1(V, destMap_f, &met_fifo_info1);
    DIAG_INFO_U32_HEX(pos, "dest-map", dest_map)
    if (!(dest_map >> 18))
    {
        DIAG_INFO_CHAR(pos, "forward-type", "UCAST")
        return CTC_E_NONE;
    }

    DIAG_INFO_CHAR(pos, "forward-type", "MCAST")
    DIAG_INFO_UINT32(pos, "mcast-group", dest_map & 0xFFFF)

    cmd = DRV_IOR(MetFifoCtl_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &MetFifoCtl));

    cmd = DRV_IOR(BufferStoreXCtl_t, BufferStoreXCtl_xMetPtrEn_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_DP_EN(cmd,0), &xmetptr_en));
    cmd = DRV_IOR(BufferStoreXCtl_t, BufferStoreXCtl_xMetPtrEn_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_DP_EN(cmd,1), &xmetptr_en1));

    drv_usw_ftm_get_entry_num(lchip, DsMetVectorSlim1X_t, &entry_num);
    if(entry_num > 0)
    {
        return CTC_E_NONE;
    }

    if((xmetptr_en1||xmetptr_en)&&(dest_map == DIAG_DESTMAPRESERVED_MC_XFIELD ))
    {
        return CTC_E_NONE;
    }
    else if((GetMetFifoCtl(V, groupIdDefaultEntryMin_f, &MetFifoCtl) <= (dest_map&0x3FFFF)) && (dest_map&0x3FFFF) <= GetMetFifoCtl(V, groupIdDefaultEntryMax_f, &MetFifoCtl))
    {
        nextMetEntryPtr = ((dest_map&0x3FFFF) << GetMetFifoCtl(V, groupIdDefaultEntryShift_f, &MetFifoCtl)) + GetMetFifoCtl(V, groupIdDefaultEntryBase_f, &MetFifoCtl);
    }
    else
    {
        nextMetEntryPtr = (dest_map&0x3FFFF) +  GetMetFifoCtl(V, groupIdBase_f, &MetFifoCtl);
    }
    drv_usw_ftm_get_entry_num(lchip, DsMetVector4X_t, &entry_num);
    for (count=0; count < 4096; count++)
    {
        metEntryPtr =  nextMetEntryPtr + GetMetFifoCtl(V, dsMetEntryBase_f, &MetFifoCtl);
        if((metEntryPtr&0xFFFFC) >= entry_num)
        {
            return CTC_E_NONE;
        }
        cmd = DRV_IOR(DsMetVector4X_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, (metEntryPtr&0xFFFFC), DRV_CMD_PP_EN(cmd), &ds_met4x));
        if((0 == (metEntryPtr&0x3)) && (DRV_ENUM(DRV_METENTRYTYPE_PORTBMP4X) == GetDsMetVector4X(V, metEntryType_f, &ds_met4x)))
        {
            metType = DRV_ENUM(DRV_METENTRYTYPE_PORTBMP4X);
            GetDsMetVector4X(A, portBitmap0_f, &ds_met4x, &(port_bitmap[0]));
            GetDsMetVector4X(A, portBitmap1_f, &ds_met4x, &(port_bitmap[3]));
            GetDsMetVector4X(A, portBitmap2_f, &ds_met4x, &(port_bitmap[7]));
        }
        else if(CTC_IS_BIT_SET(metEntryPtr, 0))
        {

            if(CTC_IS_BIT_SET(metEntryPtr, 1))
            {
                sal_memcpy((uint8*)&ds_met1x, ((uint8 *)&ds_met4x) + DRV_TABLE_ENTRY_SIZE(lchip, DsMetVector2X_t) + DRV_TABLE_ENTRY_SIZE(lchip, DsMetVector1X_t), DRV_TABLE_ENTRY_SIZE(lchip, DsMetVector1X_t));
            }
            else
            {
                sal_memcpy((uint8*)&ds_met1x, ((uint8 *)&ds_met4x) + DRV_TABLE_ENTRY_SIZE(lchip, DsMetVector1X_t), DRV_TABLE_ENTRY_SIZE(lchip, DsMetVector1X_t));
            }

            if(DRV_ENUM(DRV_METENTRYTYPE_PORTBMP1X) == GetDsMetVector1X(V, metEntryType_f, &ds_met1x))
            {
                metType = DRV_ENUM(DRV_METENTRYTYPE_PORTBMP1X);
                port_bitmap_base = (((((uint32*)&ds_met1x)[4])>>8)&0xFF);
                GetDsMetVector1X(A, portBitmap0_f, &ds_met1x, &(port_bitmap[3*port_bitmap_base]));
            }
            else
            {
                metType = DRV_ENUM(DRV_METENTRYTYPE_LINKLIST) ;
            }
        }
        else
        {
            if(CTC_IS_BIT_SET(metEntryPtr, 1))
            {
                sal_memcpy((uint8*)&ds_met2x, ((uint8 *)&ds_met4x) + DRV_TABLE_ENTRY_SIZE(lchip, DsMetVector2X_t), DRV_TABLE_ENTRY_SIZE(lchip, DsMetVector2X_t));
            }
            else
            {
                sal_memcpy((uint8*)&ds_met2x, ((uint8 *)&ds_met4x), DRV_TABLE_ENTRY_SIZE(lchip, DsMetVector2X_t));
            }
            if(DRV_ENUM(DRV_METENTRYTYPE_PORTBMP2X) == GetDsMetVector2X(V, metEntryType_f, &ds_met2x))
            {
                metType = DRV_ENUM(DRV_METENTRYTYPE_PORTBMP2X);
                port_bitmap_base = (((((uint32*)&ds_met2x)[9])>>8)&0xFF);
                GetDsMetVector2X(A, portBitmap0_f, &ds_met2x, &(port_bitmap[3*port_bitmap_base]));
                GetDsMetVector2X(A, portBitmap1_f, &ds_met2x, &(port_bitmap[3*port_bitmap_base + 3]));
            }
            else
            {
                 sal_memcpy((uint8*)&ds_met1x, ((uint8 *)&ds_met2x), DRV_TABLE_ENTRY_SIZE(lchip, DsMetVector1X_t));
                 if(DRV_ENUM(DRV_METENTRYTYPE_PORTBMP1X)  == GetDsMetVector1X(V, metEntryType_f, &ds_met1x))
                 {
                    metType = DRV_ENUM(DRV_METENTRYTYPE_PORTBMP1X);
                    port_bitmap_base = (((((uint32*)&ds_met1x)[4])>>8)&0xFF);
                    GetDsMetVector1X(A, portBitmap0_f, &ds_met1x, &(port_bitmap[3*port_bitmap_base]));
                 }
                 else
                 {
                    metType =  DRV_ENUM(DRV_METENTRYTYPE_LINKLIST);
                 }
            }
        }

        sal_sprintf(str, "met-entry-%d", count);
        DIAG_INFO_CHAR(pos, str, "HIT")
        DIAG_INFO_CHAR(pos, "table-name", STR_ARRAY(MetEntryType,(metType - DRV_ENUM(DRV_METENTRYTYPE_LINKLIST))))
        DIAG_INFO_UINT32(pos, "table-index", metEntryPtr)
        if(DRV_ENUM(DRV_METENTRYTYPE_LINKLIST) == metType)
        {
            DIAG_INFO_CHAR(pos, "met-mode", "link-list")
            end_local_re=GetDsMetEntry1X(V, endLocalRep_f, &ds_met1x);
            ucastId = GetDsMetEntry1X(V, ucastId_f, &ds_met1x);
            value = GetDsMetEntry1X(V, replicationCtl_f, &ds_met1x);

            if(GetDsMetEntry1X(V, remoteChip_f, &ds_met1x))
            {
                DIAG_INFO_CHAR(pos, "to-remote-chip", "YES")
            }
            else if(GetDsMetEntry1X(V, apsBridgeEn_f, &ds_met1x))
            {
                DIAG_INFO_CHAR(pos, "aps-bridge", "YES")
                DIAG_INFO_UINT32(pos, "aps-group", ucastId)
            }
            else if (GetDsMetEntry1X(V, isLinkAggregation_f, &ds_met1x))
            {
                DIAG_INFO_UINT32(pos, "linkagg-group", ucastId&CTC_LINKAGGID_MASK)
                DIAG_INFO_UINT32(pos, "replication-count", value&0x1F)
                DIAG_INFO_U32_HEX(pos, "nexthop-ptr", value >> 5)
            }
            else
            {
                DIAG_INFO_U32_HEX(pos, "dest-gport", CTC_MAP_LPORT_TO_GPORT(local_chip, ucastId&0x1FF))
                DIAG_INFO_UINT32(pos, "replication-count", value&0x1F)
                DIAG_INFO_U32_HEX(pos, "nexthop-ptr", value >> 5)
            }
            nextMetEntryPtr = GetDsMetEntry1X(V, nextMetEntryPtr_f, &ds_met1x);
        }
        else
        {
            DIAG_INFO_CHAR(pos, "met-mode", "bitmap")

            if (GetDsMetVector1X(V, isLinkAggregation_f, &ds_met1x))
            {
                DIAG_INFO_CHAR(pos, "bitmap-type", "linkagg-port")
            }
            else
            {
                DIAG_INFO_CHAR(pos, "bitmap-type", "normal-gport")
            }

            if(DRV_ENUM(DRV_METENTRYTYPE_PORTBMP1X)  == metType)
            {
                nextMetEntryPtr = GetDsMetVector1X(V, nextMetEntryPtr_f, &ds_met1x);
            }
            else if(DRV_ENUM(DRV_METENTRYTYPE_PORTBMP2X)  == metType)
            {
                nextMetEntryPtr = GetDsMetVector2X(V, nextMetEntryPtr_f, &ds_met2x);
            }
            else
            {
                nextMetEntryPtr = GetDsMetVector4X(V, nextMetEntryPtr_f, &ds_met4x);
            }

            DIAG_INFO_U32_LIST(pos, "port-bitmap", port_bitmap, 16)
        }

        if (GetDbgFwdMetFifoInfo2(V, valid_f, &met_fifo_info2))
        {
            uint8  rep_ctl_utype = 0;
            uint8  pkt_type = 0;
            TempDsReplicationCtl_m rep_ctl;
            char* const pkt_type_desc[] = {
                    "ETHERNET", "IPV4", "MPLS",     "IPV6",
                    "MPLSUP",   "IP",   "FLEXIBLE", "RESERVED"
                };
            if (GetDbgFwdMetFifoInfo2(V, enqueueDiscard_f, &met_fifo_info2))
            {
                DIAG_INFO_CHAR(pos, "drop-desc", "enqueue-discard")
                p_rslt->dest_type = CTC_DIAG_DEST_DROP;
            }
            GetDbgFwdMetFifoInfo2(A, replicationCtl_f, &met_fifo_info2, &rep_ctl);
            rep_ctl_utype = GetTempDsReplicationCtl(V, uType_f, &rep_ctl);
            switch(rep_ctl_utype)
            {
                case 0: /*exception*/
                {
                    pkt_type = GetTempDsReplicationCtl(V, u_g0_exceptionPacketType_f, &rep_ctl);
                    DIAG_INFO_CHAR(pos, "exception-from-sgmac", GetTempDsReplicationCtl(V, u_g0_exceptionFromSgmac_f, &rep_ctl)? "Yes": "No")
                    DIAG_INFO_UINT32(pos, "exception-id", GetTempDsReplicationCtl(V, u_g0_exceptionId_f, &rep_ctl))
                    DIAG_INFO_CHAR(pos, "exception-packet-type", pkt_type_desc[pkt_type])
                }
                break;
                case 1: /*nexthop*/
                {
                    DIAG_INFO_U32_HEX(pos, "rep-nexthop-ptr", GetTempDsReplicationCtl(V, u_g1_nextHopPtr_f, &rep_ctl))
                }
                break;
                case 2: /*replication*/
                {
                    DIAG_INFO_CHAR(pos, "last-rep", GetTempDsReplicationCtl(V, u_g2_lastRep_f, &rep_ctl)? "Yes": "No")
                    DIAG_INFO_U32_HEX(pos, "rep-hdr-ptr", GetTempDsReplicationCtl(V, u_g2_logicalRepHeadPtr_f, &rep_ctl))
                }
                break;
                default:
                break;
            }
        }

        if ((GetMetFifoCtl(V, metEntryPtrTail_f, &MetFifoCtl)) == nextMetEntryPtr || end_local_re )
        {
            break;
        }

    }
    return CTC_E_NONE;
}



STATIC int32
_sys_at_diag_pkt_trace_get_tm_queue_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint32 channel = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_TM;
    DbgFwdQWriteInfo_m qwrite_info;

    sal_memset(&qwrite_info, 0, sizeof(DbgFwdQWriteInfo_m));
    cmd = DRV_IOR(DbgFwdQWriteInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &qwrite_info));

    if (!GetDbgFwdQWriteInfo(V, valid_f, &qwrite_info))
    {
        return CTC_E_NONE;
    }
    DIAG_INFO_NONE(pos, "Queue")
    p_rslt->position = CTC_DIAG_TRACE_POS_TM;
    channel = GetDbgFwdQWriteInfo(V, channelId_f, &qwrite_info);
    DIAG_INFO_UINT32(pos, "channel-id", channel)
    DIAG_INFO_UINT32(pos, "queue-offset", GetDbgFwdQWriteInfo(V, queueOffset_f, &qwrite_info))
    if (!CTC_FLAG_ISSET(p_rslt->flags, CTC_DIAG_TRACE_RSTL_FLAG_MC_GROUP))
    {
        p_rslt->channel = channel;
        p_rslt->flags |= CTC_DIAG_TRACE_RSTL_FLAG_CHANNLE;
    }
    if (channel == MCHIP_CAP(SYS_CAP_CHANID_ILOOP))
    {
        p_rslt->loop_flags |= CTC_DIAG_LOOP_FLAG_ILOOP;
    }
    if (channel == MCHIP_CAP(SYS_CAP_CHANID_ELOOP))
    {
        p_rslt->loop_flags |= CTC_DIAG_LOOP_FLAG_ELOOP;
    }
    DIAG_INFO_UINT32(pos, "pp-dest-port", GetDbgFwdQWriteInfo(V, ppDestPort_f, &qwrite_info))
    DIAG_INFO_CHAR(pos, "final-drop-valid", GetDbgFwdQWriteInfo(V, finalDropValid_f, &qwrite_info)? DIAG_YES : DIAG_NO)
    if (GetDbgFwdQWriteInfo(V, tcamResultValid_f, &qwrite_info))
    {
        DIAG_INFO_UINT32(pos, "tcam-hit-index", GetDbgFwdQWriteInfo(V, hitIndex_f, &qwrite_info))
    }

    return CTC_E_NONE;
}

STATIC int32
_sys_at_diag_get_pkt_trace_pos_ipe(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint32 value = 0;
    char *pp_info[] = {"IPE:PP-ID 0","IPE:PP-ID 1","IPE:PP-ID 2","IPE:PP-ID 3","IPE:PP-ID 4","IPE:PP-ID 5","IPE:PP-ID 6","IPE:PP-ID 7"};
    uint8 pp_id = lchip - SYS_PP_BASE(lchip);
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;

    cmd = DRV_IOR(DbgIpeLkpMgrInfo_t, DbgIpeLkpMgrInfo_valid_f);
    DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &value);
    if (p_rslt->watch_point != CTC_DIAG_TRACE_POINT_IPE_SCL || value == 0)
    {
        return CTC_E_NONE;
    }

    DIAG_INFO_NONE(pos, "------------------------------------------------");
    DIAG_INFO_NONE(pos, STR_ARRAY(pp_info,pp_id));
    DIAG_INFO_NONE(pos, "------------------------------------------------");

    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_parser_info(lchip, 0, p_rslt));
    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_ipe_scl_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_ipe_intf_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_ipe_decap_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_parser_info(lchip, 1, p_rslt));
    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_lkup_mgr_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_flow_hash_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_ipe_bridge_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_ipe_route_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_ipe_fcoe_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_ipe_trill_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_ipe_phb_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_ipe_oam_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_ipe_acl_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_ipe_stmctl_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_ipe_policer_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_ipe_copp_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_ipe_learn_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_ipe_dest_info(lchip, p_rslt));

    return CTC_E_NONE;
}

STATIC int32
_sys_at_diag_get_pkt_trace_pos_tm(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint32 value = 0;
    uint32 value1 = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_TM;
    char *pp_info[] = {"TM:PP-ID 0","TM:PP-ID 1","TM:PP-ID 2","TM:PP-ID 3","TM:PP-ID 4","TM:PP-ID 5","TM:PP-ID 6","TM:PP-ID 7"};
    uint8 pp_id = lchip - SYS_PP_BASE(lchip);

    cmd = DRV_IOR(DbgFwdBufStoreInfo_t, DbgFwdBufStoreInfo_valid_f);
    DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_DP_EN(cmd,0), &value);
    value1 |= value;
    DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_DP_EN(cmd,1), &value);
    value1 |= value;
    cmd = DRV_IOR(DbgMmuErmInfoUc_t, DbgMmuErmInfoUc_valid_f);
    DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_DP_EN(cmd,0), &value);
    value1 |= value;
    cmd = DRV_IOR(DbgMmuErmInfoUc_t, DbgMmuErmInfoUc_valid_f);
    DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_DP_EN(cmd,1), &value);
    value1 |= value;
    cmd = DRV_IOR(DbgMmuErmInfoMc0_t, DbgMmuErmInfoMc0_valid_f);
    DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &value);
    value1 |= value;
    cmd = DRV_IOR(DbgMmuErmInfoMc1_t, DbgMmuErmInfoMc1_valid_f);
    DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &value);
    value1 |= value;

    if (!value1)
    {
        return CTC_E_NONE;
    }

    DIAG_INFO_NONE(pos, "------------------------------------------------");
    DIAG_INFO_NONE(pos, STR_ARRAY(pp_info,pp_id));
    DIAG_INFO_NONE(pos, "------------------------------------------------");

    if ((p_rslt->watch_point == CTC_DIAG_TRACE_POINT_IPE_SCL)
        || (p_rslt->watch_point == CTC_DIAG_TRACE_POINT_TM_BS)
        || (p_rslt->watch_point == CTC_DIAG_TRACE_POINT_OAM_TX))
    {
        CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_tm_bs_info(lchip, p_rslt));
    }
    if ((p_rslt->watch_point == CTC_DIAG_TRACE_POINT_IPE_SCL)
        || (p_rslt->watch_point == CTC_DIAG_TRACE_POINT_TM_BS)
        || (p_rslt->watch_point == CTC_DIAG_TRACE_POINT_TM_MET)
        || (p_rslt->watch_point == CTC_DIAG_TRACE_POINT_OAM_TX))
    {
        CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_tm_met_info(lchip, p_rslt));
        CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_tm_queue_info(lchip, p_rslt));
    }
    return CTC_E_NONE;
}


STATIC int32
_sys_at_diag_get_pkt_trace_pos_epe(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint32 value = 0;

    cmd = DRV_IOR(DbgEpeHdrAdjInfo_t, DbgEpeHdrAdjInfo_valid_f);
    DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &value);
    if (p_rslt->watch_point == CTC_DIAG_TRACE_POINT_OAM_ADJ || value == 0)
    {
        return CTC_E_NONE;
    }
    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_epe_hdj_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_parser_info(lchip, 2, p_rslt));
    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_epe_nh_map_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_epe_scl_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_epe_edit_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_epe_acl_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_epe_copp_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_ipfix_info(lchip, p_rslt, 1));
    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_epe_oam_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_epe_xedit_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_epe_pkt_rw_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_epe_hdr_edit_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_epe_dot1ae_info(lchip, p_rslt));
    return CTC_E_NONE;
}

STATIC int32
_sys_at_diag_get_pkt_trace_pos_oam(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint32 value = 0;
    char *core_info[] = {"OAM:CORE-ID 0", "OAM:CORE-ID 1"};
    uint8 core_id = (lchip != drv_vchip_get_pp_base(lchip))? 1: 0;
    uint8 pos = CTC_DIAG_TRACE_POS_OAM;

    if ((p_rslt->watch_point == CTC_DIAG_TRACE_POINT_IPE_SCL)
        || (p_rslt->watch_point == CTC_DIAG_TRACE_POINT_TM_BS)
        || (p_rslt->watch_point == CTC_DIAG_TRACE_POINT_TM_MET)
        || (p_rslt->watch_point == CTC_DIAG_TRACE_POINT_OAM_ADJ))
    {
        cmd = DRV_IOR(DbgOamHdrAdj_t, DbgOamHdrAdj_valid_f);
        DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &value);

        if(value == 0)
        {
            return CTC_E_NONE;
        }
        DIAG_INFO_NONE(pos, "------------------------------------------------");
        DIAG_INFO_NONE(pos, STR_ARRAY(core_info,core_id));
        DIAG_INFO_NONE(pos, "------------------------------------------------");

        CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_oam_rx_info(lchip, p_rslt));
    }
    if (p_rslt->watch_point == CTC_DIAG_TRACE_POINT_OAM_TX)
    {
        cmd = DRV_IOR(DbgOamTxProc_t, DbgOamTxProc_valid_f);
        DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &value);
        if(value == 0)
        {
            return CTC_E_NONE;
        }
        DIAG_INFO_NONE(pos, "------------------------------------------------");
        DIAG_INFO_NONE(pos, STR_ARRAY(core_info,core_id));
        DIAG_INFO_NONE(pos, "------------------------------------------------");

        CTC_ERROR_RETURN(_sys_at_diag_pkt_trace_get_oam_tx_info(lchip, p_rslt));
    }
    return CTC_E_NONE;
}

int32
sys_at_diag_pkt_trace_clear_rslt(uint8 lchip, uint32 watch_point)
{
    uint32 loop = 0;
    uint32 loop_size = 0;
    uint32 cmd = 0;
    ds_t temp_v;
    uint8 type_pp_bmp = 0;
    IpeUserIdFlowLoopCam_m ds_flow_loop_cam;
    BufStoreDebugCam_m ds_buff_store_cam;
    MetFifoDebugCam_m ds_met_fifo_cam;
    EpeHdrAdjustDebugCam_m ds_epe_dbg_cam;
    static sys_diag_pkt_trace_table_t clear_tbl[] =
    {
        /*ipe_tbl*/
        {DbgFibLkpEngineFlowHashInfo_t, DbgFibLkpEngineFlowHashInfo_valid_f},
        {DbgFibLkpEngineHostUrpfHashInfo_t, DbgFibLkpEngineHostUrpfHashInfo_valid_f},
        {DbgLpmPipelineLookupResultInfo_t, DbgLpmPipelineLookupResultInfo_valid_f},
        {DbgIpeFwdInputHeaderInfo_t, DbgIpeFwdInputHeaderInfo_valid_f},
        {DbgFibLkpEngineMacDaHashInfo_t, DbgFibLkpEngineMacDaHashInfo_valid_f},
        {DbgFibLkpEngineMacSaHashInfo_t, DbgFibLkpEngineMacSaHashInfo_valid_f},
        {DbgFibLkpEngineL3DaHashInfo_t, DbgFibLkpEngineL3DaHashInfo_valid_f},
        {DbgFibLkpEngineL3SaHashInfo_t, DbgFibLkpEngineL3SaHashInfo_valid_f},
        {DbgFibLkpEngineTcamKeyInfo_t, DbgFibLkpEngineTcamKeyInfo_valid_f},
        {DbgIpfixAccInfo0_t, DbgIpfixAccInfo0_valid_f},
        {DbgIpfixAccInfo1_t, DbgIpfixAccInfo1_valid_f},
        {DbgProgramLtidTcamEngineAclKeyInfoEgr_t, DbgProgramLtidTcamEngineAclKeyInfoEgr_valid_f},
        {DbgProgramLtidTcamEngineAclInfoEgr_t, DbgProgramLtidTcamEngineAclInfoEgr_valid_f},
        {DbgProgramAclTcamEngineAclInfoEgr0_t, DbgProgramAclTcamEngineAclInfoEgr0_valid_f},
        {DbgProgramAclTcamEngineAclInfoEgr1_t, DbgProgramAclTcamEngineAclInfoEgr1_valid_f},
        {DbgProgramAclTcamEngineAclInfoEgr2_t, DbgProgramAclTcamEngineAclInfoEgr2_valid_f},
        {DbgProgramAclTcamEngineAclInfoEgr3_t, DbgProgramAclTcamEngineAclInfoEgr3_valid_f},
        {DbgProgramAclTcamEngineAclInfoEgr4_t, DbgProgramAclTcamEngineAclInfoEgr4_valid_f},
        {DbgProgramAclTcamEngineAclInfoEgr5_t, DbgProgramAclTcamEngineAclInfoEgr5_valid_f},
        {DbgProgramAclTcamEngineAclInfoEgr6_t, DbgProgramAclTcamEngineAclInfoEgr6_valid_f},
        {DbgProgramAclTcamEngineAclInfoEgr7_t, DbgProgramAclTcamEngineAclInfoEgr7_valid_f},
        {DbgProgramAclTcamEngineAclInfoEgr8_t, DbgProgramAclTcamEngineAclInfoEgr8_valid_f},
        {DbgProgramAclTcamEngineAclInfoEgr9_t, DbgProgramAclTcamEngineAclInfoEgr9_valid_f},
        {DbgProgramAclTcamEngineAclInfoEgr10_t, DbgProgramAclTcamEngineAclInfoEgr10_valid_f},
        {DbgProgramAclTcamEngineAclInfoEgr11_t, DbgProgramAclTcamEngineAclInfoEgr11_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoEgr0_t, DbgProgramAclTcamEngineAclKeyInfoEgr0_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoEgr1_t, DbgProgramAclTcamEngineAclKeyInfoEgr1_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoEgr2_t, DbgProgramAclTcamEngineAclKeyInfoEgr2_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoEgr3_t, DbgProgramAclTcamEngineAclKeyInfoEgr3_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoEgr4_t, DbgProgramAclTcamEngineAclKeyInfoEgr4_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoEgr5_t, DbgProgramAclTcamEngineAclKeyInfoEgr5_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoEgr6_t, DbgProgramAclTcamEngineAclKeyInfoEgr6_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoEgr7_t, DbgProgramAclTcamEngineAclKeyInfoEgr7_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoEgr8_t, DbgProgramAclTcamEngineAclKeyInfoEgr8_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoEgr9_t, DbgProgramAclTcamEngineAclKeyInfoEgr9_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoEgr10_t, DbgProgramAclTcamEngineAclKeyInfoEgr10_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoEgr11_t, DbgProgramAclTcamEngineAclKeyInfoEgr11_valid_f},
        {DbgProgramLtidTcamEngineAclKeyInfoIgr_t, DbgProgramLtidTcamEngineAclKeyInfoIgr_valid_f},
        {DbgProgramLtidTcamEngineAclInfoIgr_t, DbgProgramLtidTcamEngineAclInfoIgr_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoIgr0_t, DbgProgramAclTcamEngineAclKeyInfoIgr0_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoIgr1_t, DbgProgramAclTcamEngineAclKeyInfoIgr1_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoIgr2_t, DbgProgramAclTcamEngineAclKeyInfoIgr2_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoIgr3_t, DbgProgramAclTcamEngineAclKeyInfoIgr3_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoIgr4_t, DbgProgramAclTcamEngineAclKeyInfoIgr4_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoIgr5_t, DbgProgramAclTcamEngineAclKeyInfoIgr5_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoIgr6_t, DbgProgramAclTcamEngineAclKeyInfoIgr6_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoIgr7_t, DbgProgramAclTcamEngineAclKeyInfoIgr7_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoIgr8_t, DbgProgramAclTcamEngineAclKeyInfoIgr8_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoIgr9_t, DbgProgramAclTcamEngineAclKeyInfoIgr9_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoIgr10_t, DbgProgramAclTcamEngineAclKeyInfoIgr10_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoIgr11_t, DbgProgramAclTcamEngineAclKeyInfoIgr11_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoIgr12_t, DbgProgramAclTcamEngineAclKeyInfoIgr12_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoIgr13_t, DbgProgramAclTcamEngineAclKeyInfoIgr13_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoIgr14_t, DbgProgramAclTcamEngineAclKeyInfoIgr14_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoIgr15_t, DbgProgramAclTcamEngineAclKeyInfoIgr15_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoIgr16_t, DbgProgramAclTcamEngineAclKeyInfoIgr16_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoIgr17_t, DbgProgramAclTcamEngineAclKeyInfoIgr17_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoIgr18_t, DbgProgramAclTcamEngineAclKeyInfoIgr18_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoIgr19_t, DbgProgramAclTcamEngineAclKeyInfoIgr19_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoIgr20_t, DbgProgramAclTcamEngineAclKeyInfoIgr20_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoIgr21_t, DbgProgramAclTcamEngineAclKeyInfoIgr21_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoIgr22_t, DbgProgramAclTcamEngineAclKeyInfoIgr22_valid_f},
        {DbgProgramAclTcamEngineAclKeyInfoIgr23_t, DbgProgramAclTcamEngineAclKeyInfoIgr23_valid_f},
        {DbgProgramAclTcamEngineAclInfoIgr0_t, DbgProgramAclTcamEngineAclInfoIgr0_valid_f},
        {DbgProgramAclTcamEngineAclInfoIgr1_t, DbgProgramAclTcamEngineAclInfoIgr1_valid_f},
        {DbgProgramAclTcamEngineAclInfoIgr2_t, DbgProgramAclTcamEngineAclInfoIgr2_valid_f},
        {DbgProgramAclTcamEngineAclInfoIgr3_t, DbgProgramAclTcamEngineAclInfoIgr3_valid_f},
        {DbgProgramAclTcamEngineAclInfoIgr4_t, DbgProgramAclTcamEngineAclInfoIgr4_valid_f},
        {DbgProgramAclTcamEngineAclInfoIgr5_t, DbgProgramAclTcamEngineAclInfoIgr5_valid_f},
        {DbgProgramAclTcamEngineAclInfoIgr6_t, DbgProgramAclTcamEngineAclInfoIgr6_valid_f},
        {DbgProgramAclTcamEngineAclInfoIgr7_t, DbgProgramAclTcamEngineAclInfoIgr7_valid_f},
        {DbgProgramAclTcamEngineAclInfoIgr8_t, DbgProgramAclTcamEngineAclInfoIgr8_valid_f},
        {DbgProgramAclTcamEngineAclInfoIgr9_t, DbgProgramAclTcamEngineAclInfoIgr9_valid_f},
        {DbgProgramAclTcamEngineAclInfoIgr10_t, DbgProgramAclTcamEngineAclInfoIgr10_valid_f},
        {DbgProgramAclTcamEngineAclInfoIgr11_t, DbgProgramAclTcamEngineAclInfoIgr11_valid_f},
        {DbgProgramAclTcamEngineAclInfoIgr12_t, DbgProgramAclTcamEngineAclInfoIgr12_valid_f},
        {DbgProgramAclTcamEngineAclInfoIgr13_t, DbgProgramAclTcamEngineAclInfoIgr13_valid_f},
        {DbgProgramAclTcamEngineAclInfoIgr14_t, DbgProgramAclTcamEngineAclInfoIgr14_valid_f},
        {DbgProgramAclTcamEngineAclInfoIgr15_t, DbgProgramAclTcamEngineAclInfoIgr15_valid_f},
        {DbgProgramAclTcamEngineAclInfoIgr16_t, DbgProgramAclTcamEngineAclInfoIgr16_valid_f},
        {DbgProgramAclTcamEngineAclInfoIgr17_t, DbgProgramAclTcamEngineAclInfoIgr17_valid_f},
        {DbgProgramAclTcamEngineAclInfoIgr18_t, DbgProgramAclTcamEngineAclInfoIgr18_valid_f},
        {DbgProgramAclTcamEngineAclInfoIgr19_t, DbgProgramAclTcamEngineAclInfoIgr19_valid_f},
        {DbgProgramAclTcamEngineAclInfoIgr20_t, DbgProgramAclTcamEngineAclInfoIgr20_valid_f},
        {DbgProgramAclTcamEngineAclInfoIgr21_t, DbgProgramAclTcamEngineAclInfoIgr21_valid_f},
        {DbgProgramAclTcamEngineAclInfoIgr22_t, DbgProgramAclTcamEngineAclInfoIgr22_valid_f},
        {DbgProgramAclTcamEngineAclInfoIgr23_t, DbgProgramAclTcamEngineAclInfoIgr23_valid_f},
        {DbgUserIdHashEngineForUserId0Info_t, DbgUserIdHashEngineForUserId0Info_valid_f},
        {DbgUserIdHashEngineForUserId1Info_t, DbgUserIdHashEngineForUserId1Info_valid_f},
        {DbgUserIdTcamEngineForUserId0Info_t, DbgUserIdTcamEngineForUserId0Info_valid_f},
        {DbgUserIdTcamEngineForUserId1Info_t, DbgUserIdTcamEngineForUserId1Info_valid_f},
        {DbgIpeEcmpProcInfo_t, DbgIpeEcmpProcInfo_valid_f},
        {DbgIpeFwdCoPPInfo_t, DbgIpeFwdCoppInfo_valid_f},
        {DbgIpeFwdPolicingInfo_t, DbgIpeFwdPolicingInfo_valid_f},
        {DbgIpeFwdProcessInfo_t, DbgIpeFwdProcessInfo_valid_f},
        {DbgIpeAclProcInfo0_t, DbgIpeAclProcInfo0_valid_f},
        {DbgIpeAclProcInfo1_t, DbgIpeAclProcInfo1_valid_f},
        {DbgIpeFwdStormCtlInfo_t, DbgIpeFwdStormCtlInfo_valid_f},
        {DbgIpeIntfMapperInfo_t, DbgIpeIntfMapperInfo_valid_f},
        {DbgIpeMplsDecapInfo_t, DbgIpeMplsDecapInfo_valid_f},
        {DbgIpeUserIdInfo_t, DbgIpeUserIdInfo_valid_f},
        {DbgIpeLkpMgrInfo_t, DbgIpeLkpMgrInfo_valid_f},
        {DbgParserFromIpeIntfInfo_t, DbgParserFromIpeIntfInfo_valid_f},
        {DbgIpeFcoeInfo_t, DbgIpeFcoeInfo_valid_f},
        {DbgIpeFlowProcessInfo_t, DbgIpeFlowProcessInfo_valid_f},
        {DbgIpeIpRoutingInfo_t, DbgIpeIpRoutingInfo_valid_f},
        {DbgIpeMacBridgingInfo_t, DbgIpeMacBridgingInfo_valid_f},
        {DbgIpeMacLearningInfo_t, DbgIpeMacLearningInfo_valid_f},
        {DbgIpeOamInfo_t, DbgIpeOamInfo_valid_f},
        {DbgIpePacketProcessInfo_t, DbgIpePacketProcessInfo_valid_f},
        {DbgIpePerHopBehaviorInfo_t, DbgIpePerHopBehaviorInfo_valid_f},
        {DbgIpeTrillInfo_t, DbgIpeTrillInfo_valid_f},
        {DbgLagEngineInfo_t, DbgLagEngineInfo_valid_f},
        {DbgLpmTcamEngineResult0Info_t, DbgLpmTcamEngineResult0Info_valid_f},
        {DbgLpmTcamEngineResult1Info_t, DbgLpmTcamEngineResult1Info_valid_f},
        {DbgParserFromIpeHdrAdjInfo_t, DbgParserFromIpeHdrAdjInfo_valid_f},
        {DbgUserIdHashEngineForUserId0Info_t, DbgUserIdHashEngineForUserId0Info_valid_f},
        {DbgUserIdHashEngineForUserId1Info_t, DbgUserIdHashEngineForUserId1Info_valid_f},
        {DbgEfdEngineInfo_t, DbgEfdEngineInfo_valid_f},
        {DbgFibLkpEngineFibHashInfo_t, DbgFibLkpEngineFibHashInfo_valid_f},
        {DbgFibLkpEngineFibHost0KeyInfo_t, DbgFibLkpEngineFibHost0KeyInfo_valid_f},
        {DbgEcmpDlbEngineInfo_t, DbgEcmpDlbEngineInfo_valid_f},
        {DbgIpeLookupManagerOuterL2Decoder_t, DbgIpeLookupManagerOuterL2Decoder_valid_f},
        {DbgMplsHashEngineForLabel0Info_t, DbgMplsHashEngineForLabel0Info_valid_f},
        {DbgMplsHashEngineForLabel1Info_t, DbgMplsHashEngineForLabel1Info_valid_f},
        {DbgMplsHashEngineForLabel2Info_t, DbgMplsHashEngineForLabel2Info_valid_f},
        {IpeUserIdFlowCtl_t, IpeUserIdFlowCtl_flowEn_f},
        {DbgSCLEngineUdfDecoderInfo_t,DbgSCLEngineUdfDecoderInfo_valid_f},
        {DbgIpeLookupManagerUdfDecoder_t,DbgIpeLookupManagerUdfDecoder_valid_f},
        {DbgIpeLookupManagerUdfDecoder0_t,DbgIpeLookupManagerUdfDecoder0_valid_f},
        {DbgFibLkpEngineXLookupInfo_t,DbgFibLkpEngineXLookupInfo_valid_f},
        {IpeUserIdFlowCam_t, IpeUserIdFlowCam_g_0_isDebuggedPkt_f},
        {IpeUserIdFlowCam_t, IpeUserIdFlowCam_g_1_isDebuggedPkt_f},
        {IpeUserIdFlowCam_t, IpeUserIdFlowCam_g_0_data_f},
        {IpeUserIdFlowCam_t, IpeUserIdFlowCam_g_1_data_f},
        {DebugSessionStatusCtl_t, DebugSessionStatusCtl_isFree_f},
        {DbgSCLEngineDecoderSclInputInfo_t,DbgSCLEngineDecoderSclInputInfo_valid_f},
        {DbgSCLEngineL2DecoderInfo_t,DbgSCLEngineL2DecoderInfo_valid_f},
        {DbgSCLEngineL3DecoderInfo_t,DbgSCLEngineL3DecoderInfo_valid_f},
        {DbgSCLEngineL4DecoderInfo_t,DbgSCLEngineL4DecoderInfo_valid_f},
        {DbgIpeLookupManagerOuterL3Decoder_t,DbgIpeLookupManagerOuterL3Decoder_valid_f},
        {DbgIpeLookupManagerOuterL4Decoder_t,DbgIpeLookupManagerOuterL4Decoder_valid_f},
        {DbgIpeLookupManagerInnerL2Decoder_t,DbgIpeLookupManagerInnerL2Decoder_valid_f},
        {DbgIpeLookupManagerInnerL3Decoder_t,DbgIpeLookupManagerInnerL3Decoder_valid_f},
        {DbgIpeLookupManagerInnerL4Decoder_t,DbgIpeLookupManagerInnerL4Decoder_valid_f},
        {DbgIpeFlowProcessInfo2_t, DbgIpeFlowProcessInfo2_valid_f},

        /*bsr_tbl*/
        {DbgFwdBufStoreInfo_t, DbgFwdBufRetrvInfo_valid_f},
        {DbgFwdBufStoreInfo2_t, DbgFwdBufStoreInfo2_valid_f},
        {DbgFwdBufStoreInfo_t, DbgFwdBufStoreInfo_valid_f},
        {BufStoreDebugCtl_t, BufStoreDebugCtl_debugLookupEn_f},
        {DbgXSecTxInfo_t,DbgXSecTxInfo_valid_f},
        {DbgIpfixMmuAccInfo_t, DbgIpfixMmuAccInfo_valid_f},
        {DbgMmuErmInfoMc1_t, DbgMmuErmInfoMc1_valid_f},
        {DbgMmuErmInfoMc0_t, DbgMmuErmInfoMc0_valid_f},
        {DbgMmuErmInfoUc_t,DbgMmuErmInfoUc_valid_f},
        {DbgMmuIrmInfoMc_t,DbgMmuIrmInfoMc_valid_f},
        {DbgMmuIrmInfoUc_t,DbgMmuIrmInfoUc_valid_f},

         /*epe_tbl*/
        {DbgOamHashEngineFromEpeOam0Info_t, DbgOamHashEngineFromEpeOam0Info_valid_f},
        {DbgOamHashEngineFromIpeOam0Info_t, DbgOamHashEngineFromIpeOam0Info_valid_f},
        {DbgEpeAclInfo_t, DbgEpeAclInfo_valid_f},
        {DbgEpeClassificationInfo_t, DbgEpeClassificationInfo_valid_f},
        {DbgEpeOamInfo_t, DbgEpeOamInfo_valid_f},
        {DbgEpeHdrAdjInfo_t, DbgEpeHdrAdjInfo_valid_f},
        {DbgEpeHdrEditCflexHdrInfo_t, DbgEpeHdrEditCflexHdrInfo_valid_f},
        {DbgEpeHdrEditInfo_t, DbgEpeHdrEditInfo_valid_f},
        {DbgEpeEgressEditInfo_t, DbgEpeEgressEditInfo_valid_f},
        {DbgEpePldProcInfo_t, DbgEpePldProcInfo_valid_f},
        {DbgParserFromEpeHdrAdjInfo_t, DbgParserFromEpeHdrAdjInfo_valid_f},
        {DbgEpeNextHopInfo_t, DbgEpeNextHopInfo_valid_f},
        {DbgEpeHdrAdjHeaderInfo_t, DbgEpeHdrAdjHeaderInfo_valid_f},
        {DbgEpeCoPPInfo_t, DbgEpeCoPPInfo_valid_f},
        {DbgEpePktRwInfo_t, DbgEpePktRwInfo_valid_f},
        {DbgEpeHdrEditHeaderInfo_t, DbgEpeHdrEditHeaderInfo_valid_f},
        {DbgEgrSclHash0_t, DbgEgrSclHash0_valid_f},
        {DbgEgrSclHash1_t, DbgEgrSclHash1_valid_f},
        {EpeHdrAdjustCtl_t, EpeHdrAdjustCtl_debugLookupEn_f},
        {EpeHdrAdjustChanCtl_t, EpeHdrAdjustChanCtl_debugIsFree_f},
        {DbgEpeHdrAdjInfo2_t,DbgEpeHdrAdjInfo2_valid_f},
        {DbgEpeEgressEditInfo2_t,DbgEpeEgressEditInfo2_valid_f},
        {DbgEpeXEgressEditInfo_t,DbgEpeXEgressEditInfo_valid_f},

        /*met_tbl*/
        {DbgFwdMetFifoInfo10_t, DbgFwdMetFifoInfo10_valid_f},
        {DbgFwdMetFifoInfo11_t, DbgFwdMetFifoInfo11_valid_f},
        {DbgFwdMetFifoInfo12_t, DbgFwdMetFifoInfo12_valid_f},
        {DbgFwdMetFifoInfo13_t, DbgFwdMetFifoInfo13_valid_f},
        {DbgFwdMetFifoInfo2_t, DbgFwdMetFifoInfo2_valid_f},
        {DbgFwdQWriteInfo_t, DbgFwdQWriteInfo_valid_f},
        {MetFifoCtl_t, MetFifoCtl_debugLookupEn_f},
        {DbgFwdBufStoreInfo2_t, DbgFwdBufStoreInfo2_valid_f},
        {DbgFwdBufStoreInfo_t, DbgFwdBufStoreInfo_valid_f},

        /*oam_rx_tbl*/
        {DbgOamHdrEdit_t, DbgOamHdrEdit_valid_f},
        {DbgOamHdrAdj_t, DbgOamHdrAdj_valid_f},
        {DbgOamHdrAdj_t, DbgOamHdrAdj_debug1stPkt_f},
        {DbgOamHdrAdj_t, DbgOamHdrAdj_debugSessionEn_f},
        {DbgOamHdrAdj_t, DbgOamHdrAdj_mepIndex_f},
        {DbgOamHdrAdj_t, DbgOamHdrAdj_debugUseMepIdx_f},
        {DbgOamParser_t, DbgOamParser_valid_f},
        {DbgOamDefectProc_t, DbgOamDefectProc_valid_f},
        {DbgOamRxProc_t, DbgOamRxProc_valid_f},
        {DbgOamApsSwitch_t, DbgOamApsSwitch_valid_f},
        {DbgOamApsSwitch_t, DbgOamApsSwitch_mepIndex_f},
        {DbgOamApsSwitch_t, DbgOamApsSwitch_debugUseMepIdx_f},
        {DbgOamApsProcess_t, DbgOamApsProcess_valid_f},
        {DbgOamApsProcess_t, DbgOamApsProcess_mepIndex_f},
        {DbgOamApsProcess_t, DbgOamApsProcess_debugUseMepIdx_f},
        {DbgOamRmepHashInfo_t, DbgOamRmepHashInfo_valid_f},
        {DsMa_t, DsMa_debugSessionEn_f},

        /*oam_tx_tbl*/
        {DbgOamTxProc_t, DbgOamTxProc_valid_f},
        {DbgOamTxProc_t, DbgOamTxProc_mepIndex_f},
        {DbgOamTxProc_t, DbgOamTxProc_debugUseMepIdx_f},
        {DbgOamTxProc_t, DbgOamTxProc_debug1stPkt_f}
    };

    sal_memset(temp_v, 0, sizeof(ds_t));
    CTC_BIT_SET(type_pp_bmp, watch_point);

    loop_size = sizeof(clear_tbl)/sizeof(sys_diag_pkt_trace_table_t);
    for (loop = 0; loop < loop_size; loop++)
    {
        cmd = DRV_IOW(clear_tbl[loop].table, clear_tbl[loop].field);
        CTC_ERROR_DUMP(DRV_FIELD_IOCTL(lchip, 0, cmd, temp_v));
    }

    sal_memset(&ds_flow_loop_cam, 0, sizeof(IpeUserIdFlowLoopCam_m));
    cmd = DRV_IOW(IpeUserIdFlowLoopCam_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &ds_flow_loop_cam));

    sal_memset(&ds_buff_store_cam, 0, sizeof(BufStoreDebugCam_m));
    cmd = DRV_IOW(BufStoreDebugCam_t, DRV_ENTRY_FLAG);
    SYS_SET_TBL_ALL_DP(lchip, cmd, ds_buff_store_cam);

    sal_memset(&ds_met_fifo_cam, 0, sizeof(MetFifoDebugCam_m));
    cmd = DRV_IOW(MetFifoDebugCam_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &ds_met_fifo_cam));

    sal_memset(&ds_epe_dbg_cam, 0, sizeof(EpeHdrAdjustDebugCam_m));
    cmd = DRV_IOW(EpeHdrAdjustDebugCam_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &ds_epe_dbg_cam));

    return CTC_E_NONE;
}


STATIC int32
_sys_at_diag_get_drop_info(uint8 lchip, ctc_diag_drop_t* p_drop)
{
    uint32 cmd = 0;
    uint16 lport = 0;
    uint8 gchip = 0;
    uint32 value[37] = {0};
    uint64 value64 = 0;
    uint32 loop_reason = 0;
    uint32 pp_id = 0;
    DsIngressDiscardStats_m  ds_igs_stats;
    DsEgressDiscardStats_m  ds_egs_stats;
    NetRxDebugStatsTable_m net_rx_debug_stats_table;
    NetRxDebugStats_m net_rx_debug_stats;
    BufStorePktErrStatsMem_m pkt_err_stats_mem;
    BufStoreErmDropStatsMem_m bsr_erm_drop_stats;
    NetTxDebugStats_m net_tx_debug_stats;
    BufStoreUcIrmDropStatsMem_m bsr_uc_irm_drop_stats;
    PreBrDebugStats_m pre_br_debug_stats;
    EpeHdrProcDebugStats_m epe_hdr_proc_debug_stats;
    EpeScheduleDebugStats_m epe_sch_debug_stats;
    BufStoreMcIrmDropStatsMem_m bsr_mc_irm_drop_stats;
    QMgrErmResrcDropCntSaturation_m qmgr_erm_drop_cnt;
    QMgrQWriteDebugStats_m qmgr_qwrite_debug_stats;
    BufStoreMcCtlDpDebugStats_m bsr_mcctl_dp_stats;
    QMgrErmDebugStats0_m qmgr_erm_stats0;
    QMgrErmDebugStats1_m qmgr_erm_stats1;
    QMgrErmDebugStats2_m qmgr_erm_stats2;
    QMgrErmDebugStats3_m qmgr_erm_stats3;
    uint32 start_lport = 0;
    uint32 end_lport = MCHIP_CAP(SYS_CAP_PORT_NUM_PER_CHIP) - 1;
    uint32 index = 0;
    uint32 txaqm_port_id = 0;
    uint8 get_detail_en = 0;
    uint16 user_reason = 0;
    uint16 drop_reason = 0;
    drv_work_platform_type_t platform_type = 0;
    uint8 lchip_base = drv_vchip_get_pp_base(lchip);
    uint8 pp_num = drv_vchip_get_pp_num(lchip);
    uint8 loop_pp = 0;
    sys_port_info_t port_info;

    drv_get_gchip_id(lchip, &gchip);
    CTC_ERROR_RETURN(drv_get_platform_type(lchip, &platform_type));

    if (p_drop->oper_type != CTC_DIAG_DROP_OPER_TYPE_GET_PORT_BMP)
    {
        if (p_drop->lport == SYS_DIAG_DROP_COUNT_SYSTEM)
        {
            goto get_system_stats;
        }
        start_lport = p_drop->lport;
        end_lport = start_lport;
    }
    if (p_drop->oper_type == CTC_DIAG_DROP_OPER_TYPE_GET_DETAIL_INFO)
    {
        user_reason = p_drop->reason;
        get_detail_en = 1;
    }

    sal_memset(&ds_igs_stats, 0, sizeof(ds_igs_stats));
    sal_memset(&ds_egs_stats, 0, sizeof(ds_egs_stats));
    sal_memset(&port_info, 0, sizeof(sys_port_info_t));

    for(pp_id = 0; pp_id < pp_num; pp_id ++)
    {
        for (lport = start_lport; lport <= end_lport; lport++)
        {
            CTC_ERROR_RETURN(sys_usw_port_api_get_com_info(lchip, lport, 0, &port_info));
            
            /* IPE feature discard*/
            for (loop_reason = SYS_AT_DISCARD_IPE_START; loop_reason <= SYS_AT_DISCARD_IPE_END; loop_reason++)
            {
                sys_at_map_drop_reason_sys_to_ctc(loop_reason, &drop_reason);
                if (get_detail_en && (user_reason != drop_reason))
                {
                    continue;
                }
                SYS_DIAG_DBG_OUT(CTC_DEBUG_LEVEL_INFO, "ipe_drop_reason:%u, discard_type:%u!\n", drop_reason, loop_reason);
                index = (lport << 6) + loop_reason - SYS_AT_DISCARD_IPE_START;
                cmd = DRV_IOR(DsIngressDiscardStats_t, DsIngressDiscardStats_packetCount_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip_base + pp_id, index, DRV_CMD_PP_EN(cmd), &value[0]));
                CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, loop_reason, value[0]));
#if(1 == SDK_WORK_PLATFORM)
            cmd = DRV_IOW(DsIngressDiscardStats_t, DRV_ENTRY_FLAG);
            DRV_IOCTL(lchip_base + pp_id, index, DRV_CMD_PP_EN(cmd), &ds_igs_stats);
#endif
            }

            /* EPE feature discard*/
            for (loop_reason = SYS_AT_DISCARD_EPE_START; loop_reason <= SYS_AT_DISCARD_EPE_END; loop_reason++)
            {
                sys_at_map_drop_reason_sys_to_ctc(loop_reason, &drop_reason);
                if (get_detail_en && (user_reason != drop_reason))
                {
                    continue;
                }
                SYS_DIAG_DBG_OUT(CTC_DEBUG_LEVEL_INFO, "epe_drop_reason:%u, discard_type:%u!\n", drop_reason, loop_reason);
                index = (lport << 6) + loop_reason - SYS_AT_DISCARD_EPE_START;
                cmd = DRV_IOR(DsEgressDiscardStats_t, DsEgressDiscardStats_packetCount_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip_base + pp_id, index, DRV_CMD_PP_EN(cmd), &value[0]));
                CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, loop_reason, value[0]));
                if (SW_SIM_PLATFORM == platform_type)
                {
                    cmd = DRV_IOW(DsEgressDiscardStats_t, DRV_ENTRY_FLAG);
                    DRV_IOCTL(lchip_base + pp_id, index, DRV_CMD_PP_EN(cmd), &ds_egs_stats);
                }
            }
            /*follow read tbl index is chan or sub_chan*/
            if(SYS_DMPS_INVALID_CHAN_ID == port_info.chan_id || SYS_DMPS_INVALID_CHAN_ID == port_info.sub_chan_id || pp_id != port_info.pp_id)
            {
                continue;
            }

            /*BSR feature discard */
            if(!(get_detail_en && (user_reason != CTC_DROP_TRAFFIC_MANAGER)))
            {
                cmd = DRV_IOR(BufStorePktErrStatsMem_t, DRV_ENTRY_FLAG);
                CTC_ERROR_RETURN(DRV_IOCTL(lchip_base + port_info.pp_id, port_info.sub_chan_id, DRV_CMD_DP_EN(cmd, port_info.dp_id),&pkt_err_stats_mem));

                value[0] = GetBufStorePktErrStatsMem(V, pktAbortCnt_f, &pkt_err_stats_mem);
                CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BSR_BUFSTORE_ABORT_TOTAL, value[0]));
                GetBufStorePktErrStatsMem(A, pktSilentDropMcIrmFailCnt_f, &pkt_err_stats_mem, &value[0]);
                CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BSR_BUFSTORE_IRM_RESRC, value[0]));
                value64 = GetBufStorePktErrStatsMem(V, pktAbortDataErrorCnt_f, &pkt_err_stats_mem) +
                        GetBufStorePktErrStatsMem(V, pktSilentDropDataErrorCnt_f, &pkt_err_stats_mem);
                CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BSR_BUFSTORE_DATA_ERR, value64));
                GetBufStorePktErrStatsMem(A, pktSilentDropCnt_f, &pkt_err_stats_mem, &value[0]);
                CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BSR_BUFSTORE_SLIENT_TOTAL, value[0]));
                value[0] = GetBufStorePktErrStatsMem(V,  pktSilentDropDestIdDiscardCnt_f, &pkt_err_stats_mem);
                CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BSR_BUFSTORE_DESTID, value[0]));
                value[0] = GetBufStorePktErrStatsMem(V,  pktSilentDropFwdChkDiscardCnt_f, &pkt_err_stats_mem);
                CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BSR_ENQ_FWD_DROP, value[0]));
                value[0] = GetBufStorePktErrStatsMem(V,  pktSilentDropMrmFailCnt_f, &pkt_err_stats_mem);
                CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BSR_BUFSTORE_MRM, value[0]));
            }
            /*Net Rx feature discard*/
            if(port_info.sub_chan_id < MCHIP_CAP(SYS_CAP_PER_DP_PHY_CHANNEL_NUM))
            {
                cmd = DRV_IOR(DsNetRxChanToPortMap_t, DsNetRxChanToPortMap_portId_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip_base + port_info.pp_id, port_info.sub_chan_id, DRV_CMD_DP_EN(cmd, port_info.dp_id), &txaqm_port_id));

                cmd = DRV_IOR(NetRxDebugStatsTable_t, DRV_ENTRY_FLAG);
                CTC_ERROR_RETURN(DRV_IOCTL(lchip_base + port_info.pp_id, txaqm_port_id, DRV_CMD_DP_EN(cmd, port_info.dp_id),&net_rx_debug_stats_table));
                GetNetRxDebugStatsTable(A, fullDropCellCnt_f, &net_rx_debug_stats_table, &value[0]);
                CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_NETRX_NO_BUFFER, value[0]));
                value[0] = GetNetRxDebugStatsTable(V, overLenErrDropCnt_f, &net_rx_debug_stats_table) +
                        GetNetRxDebugStatsTable(V, underLenErrDropCnt_f, &net_rx_debug_stats_table);
                CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_NETRX_LEN_ERROR, value[0]));
                value[0] = GetNetRxDebugStatsTable(V, pktWithErrCellCnt_f, &net_rx_debug_stats_table);
                CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_NETRX_PKT_ERROR, value[0]));
                GetNetRxDebugStatsTable(A, frameErrDropCnt_f, &net_rx_debug_stats_table, &value[0]);
                CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_NETRX_FRAME_ERROR, value[0]));
                GetNetRxDebugStatsTable(A, validByteErrCnt_f, &net_rx_debug_stats_table, &value[0]);
                CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_NETRX_VALIDBYTE_ERROR, value[0]));
                GetNetRxDebugStatsTable(A, sopErrDropCnt_f, &net_rx_debug_stats_table, &value[0]);
                CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_NETRX_SOP, value[0]));
            }
            // /*BSR ENQ feature discard */
            if(!(get_detail_en && (user_reason != CTC_DROP_BS)))
            {
                if(port_info.sub_chan_id < MCHIP_CAP(SYS_CAP_PER_DP_CHANNEL_NUM))
                {
                    cmd = DRV_IOR(BufStoreUcIrmDropStatsMem_t, DRV_ENTRY_FLAG);
                    CTC_ERROR_RETURN(DRV_IOCTL(lchip_base + port_info.pp_id, port_info.sub_chan_id, DRV_CMD_DP_EN(cmd, port_info.dp_id),&bsr_uc_irm_drop_stats));
                    GetBufStoreUcIrmDropStatsMem(A, portDropCnt_f, &bsr_uc_irm_drop_stats, &value[0]);
                    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BUFSTORE_UC_IRM_PORT_NO_BUFF, value[0]));
                    GetBufStoreUcIrmDropStatsMem(A, portScDropCnt_f, &bsr_uc_irm_drop_stats, &value[0]);
                    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BUFSTORE_UC_IRM_PORT_SC_NO_BUFF, value[0]));
                    GetBufStoreUcIrmDropStatsMem(A, portTcDropCnt_f, &bsr_uc_irm_drop_stats, &value[0]);
                    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BUFSTORE_UC_IRM_PORT_TC_NO_BUFF, value[0]));
                    GetBufStoreUcIrmDropStatsMem(A, scDropCnt_f, &bsr_uc_irm_drop_stats, &value[0]);
                    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BUFSTORE_UC_IRM_SC_BUFF, value[0]));
                    GetBufStoreUcIrmDropStatsMem(A, totalDropCnt_f, &bsr_uc_irm_drop_stats, &value[0]);
                    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BUFSTORE_UC_IRM_TATAL_DROP, value[0]));

                    cmd = DRV_IOR(BufStoreErmDropStatsMem_t, DRV_ENTRY_FLAG);
                    CTC_ERROR_RETURN(DRV_IOCTL(lchip_base + port_info.pp_id, port_info.sub_chan_id, DRV_CMD_DP_EN(cmd, port_info.dp_id),&bsr_erm_drop_stats));
                    GetBufStoreErmDropStatsMem(A, portDropCnt_f, &bsr_erm_drop_stats, &value[0]);
                    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BUFSTORE_UC_ERM_PORT_NO_BUFF, value[0]));
                    GetBufStoreErmDropStatsMem(A, portScDropCnt_f, &bsr_erm_drop_stats, &value[0]);
                    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BUFSTORE_UC_ERM_PORT_SC_NO_BUFF, value[0]));
                    GetBufStoreErmDropStatsMem(A, queueDropCnt_f, &bsr_erm_drop_stats, &value[0]);
                    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BUFSTORE_UC_ERM_QUEUE_NO_BUFF, value[0]));
                    GetBufStoreErmDropStatsMem(A, scDropCnt_f, &bsr_erm_drop_stats, &value[0]);
                    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BUFSTORE_UC_ERM_SC_BUFF, value[0]));
                    GetBufStoreErmDropStatsMem(A, totalDropCnt_f, &bsr_erm_drop_stats, &value[0]);
                    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BUFSTORE_UC_ERM_TATAL_DROP, value[0]));

                    cmd = DRV_IOR(BufStoreMcIrmDropStatsMem_t, DRV_ENTRY_FLAG);
                    CTC_ERROR_RETURN(DRV_IOCTL(lchip_base + port_info.pp_id, port_info.sub_chan_id, DRV_CMD_DP_EN(cmd, port_info.dp_id),&bsr_mc_irm_drop_stats));
                    GetBufStoreMcIrmDropStatsMem(A, portDropCnt_f, &bsr_mc_irm_drop_stats, &value[0]);
                    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BUFSTORE_MC_PORT_NO_BUFF, value[0]));
                    GetBufStoreMcIrmDropStatsMem(A, portScDropCnt_f, &bsr_mc_irm_drop_stats, &value[0]);
                    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BUFSTORE_MC_PORT_SC_NO_BUFF, value[0]));
                    GetBufStoreMcIrmDropStatsMem(A, portTcDropCnt_f, &bsr_mc_irm_drop_stats, &value[0]);
                    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BUFSTORE_MC_PORT_TC_NO_BUFF, value[0]));
                    GetBufStoreMcIrmDropStatsMem(A, scDropCnt_f, &bsr_mc_irm_drop_stats, &value[0]);
                    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BUFSTORE_MC_SC_BUFF, value[0]));
                    GetBufStoreMcIrmDropStatsMem(A, totalDropCnt_f, &bsr_mc_irm_drop_stats, &value[0]);
                    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BUFSTORE_MC_TATAL_DROP, value[0]));

                    cmd = DRV_IOR(BufStoreMcIrmDropStatsMem_t, DRV_ENTRY_FLAG);
                    CTC_ERROR_RETURN(DRV_IOCTL(lchip_base + port_info.pp_id, port_info.sub_chan_id + 26 , DRV_CMD_DP_EN(cmd, port_info.dp_id),&bsr_mc_irm_drop_stats));
                    GetBufStoreMcIrmDropStatsMem(A, portDropCnt_f, &bsr_mc_irm_drop_stats, &value[0]);
                    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BUFSTORE_MC_PORT_NO_BUFF_LOG, value[0]));
                    GetBufStoreMcIrmDropStatsMem(A, portScDropCnt_f, &bsr_mc_irm_drop_stats, &value[0]);
                    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BUFSTORE_MC_PORT_SC_NO_BUFF_LOG, value[0]));
                    GetBufStoreMcIrmDropStatsMem(A, portTcDropCnt_f, &bsr_mc_irm_drop_stats, &value[0]);
                    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BUFSTORE_MC_PORT_TC_NO_BUFF_LOG, value[0]));
                    GetBufStoreMcIrmDropStatsMem(A, scDropCnt_f, &bsr_mc_irm_drop_stats, &value[0]);
                    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BUFSTORE_MC_SC_BUFF_LOG, value[0]));
                    GetBufStoreMcIrmDropStatsMem(A, totalDropCnt_f, &bsr_mc_irm_drop_stats, &value[0]);
                    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BUFSTORE_MC_TATAL_DROP_LOG, value[0]));
                }
            }
            sal_memset(value, 0, sizeof(value));
            /* QMGrQWrite feature discard*/
            for (index = 0; index < SYS_AT_MC_QUEUE_NUM; index++)
            {
                if(get_detail_en && (user_reason != CTC_DROP_TRAFFIC_MANAGER))
                {
                    continue;
                }
                cmd = DRV_IOR(QMgrErmResrcDropCntSaturation_t, DRV_ENTRY_FLAG);
                CTC_ERROR_RETURN(DRV_IOCTL(lchip_base + port_info.pp_id, port_info.pp_id*26*2*6+ port_info.dp_id*26*6 + port_info.sub_chan_id*6 + index, DRV_CMD_DP_EN(cmd, port_info.dp_id),&qmgr_erm_drop_cnt));
                value[0] += GetQMgrErmResrcDropCntSaturation(V, dropCntFinalDropRd_f, &qmgr_erm_drop_cnt);
                value[1] += GetQMgrErmResrcDropCntSaturation(V, dropCntForwardDropRd_f, &qmgr_erm_drop_cnt);
                value[3] += GetQMgrErmResrcDropCntSaturation(V, dropCntPortDropRd_f, &qmgr_erm_drop_cnt);
                value[4] += GetQMgrErmResrcDropCntSaturation(V, dropCntPortScDropRd_f, &qmgr_erm_drop_cnt);
                value[5] += GetQMgrErmResrcDropCntSaturation(V, dropCntQueueDropRd_f, &qmgr_erm_drop_cnt);
                value[6] += GetQMgrErmResrcDropCntSaturation(V, dropCntResrcCheckDropRd_f, &qmgr_erm_drop_cnt);
                value[7] += GetQMgrErmResrcDropCntSaturation(V, dropCntScDropRd_f, &qmgr_erm_drop_cnt);
                value[8] += GetQMgrErmResrcDropCntSaturation(V, dropCntTotalDropRd_f, &qmgr_erm_drop_cnt);
            }
            CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BSR_ENQ_TOTAL_DROP, value[0]));
            CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BSR_ENQ_FWD_DROP_RD, value[1]));
            CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BSR_ENQ_PORT_NO_BUFF, value[3]));
            CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BSR_ENQ_PORT_SC_NO_BUFF, value[4]));
            CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BSR_ENQ_QUEUE_NO_BUFF, value[5]));
            CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BSR_ENQ_NO_RESRC, value[6]));
            CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BSR_ENQ_SC_NO_BUFF, value[7]));
            CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_AT_DISCARD_BSR_ENQ_TOTAL_NO_BUFF, value[8]));
        }
    }
    

get_system_stats:
    sal_memset(value, 0, sizeof(value));
    /*NetTx feature discard*/
    for(loop_pp = 0;loop_pp < pp_num ;loop_pp++)
    {
        for (index = 0; index < MCHIP_CAP(SYS_CAP_DP_MAX_NUM); index++)/* DP0 + DP1*/
        {
            if(!(get_detail_en && (user_reason != CTC_DROP_NET_TX)))
            {
                cmd = DRV_IOR(NetTxDebugStats_t, DRV_ENTRY_FLAG);
                CTC_ERROR_RETURN(DRV_IOCTL(lchip_base+loop_pp, 0, DRV_CMD_DP_EN(cmd,index), &net_tx_debug_stats));
                value[0] += GetNetTxDebugStats(V, minLenDropCnt_f, &net_tx_debug_stats);
                value[1] += GetNetTxDebugStats(V, rxNoBufCnt_f, &net_tx_debug_stats);
                value[2] = value[2] + GetNetTxDebugStats(V, rxNoEopDropCnt_f, &net_tx_debug_stats) +
                        GetNetTxDebugStats(V, rxNoSopDropCnt_f, &net_tx_debug_stats);
                value[3] += GetNetTxDebugStats(V, txErrorCnt_f, &net_tx_debug_stats);
                value[30] += GetNetTxDebugStats(V, sopDiscardCnt_f, &net_tx_debug_stats);
            }
            //PreBrDebugStats entry = 2 ,index = 1 useful with core1
            if(!(get_detail_en && (user_reason != CTC_DROP_TRAFFIC_MANAGER)))
            {
                cmd = DRV_IOR(BufStoreMcCtlDpDebugStats_t, DRV_ENTRY_FLAG);
                CTC_ERROR_RETURN(DRV_IOCTL(lchip_base+loop_pp, 0, DRV_CMD_DP_EN(cmd,index), &bsr_mcctl_dp_stats));
                value[32] += GetBufStoreMcCtlDpDebugStats(V, mcIrmC2cDropCnt_f, &bsr_mcctl_dp_stats);
                value[33] += GetBufStoreMcCtlDpDebugStats(V, mcIrmCriticalDropCnt_f, &bsr_mcctl_dp_stats);
                value[34] += GetBufStoreMcCtlDpDebugStats(V, mcIrmScDropCnt_f, &bsr_mcctl_dp_stats);
                value[35] += GetBufStoreMcCtlDpDebugStats(V, mcIrmPortDropCnt_f, &bsr_mcctl_dp_stats);
                value[36] += GetBufStoreMcCtlDpDebugStats(V, mcIrmPortScDropCnt_f, &bsr_mcctl_dp_stats);
                cmd = DRV_IOR(PreBrDebugStats_t, DRV_ENTRY_FLAG);
                CTC_ERROR_RETURN(DRV_IOCTL(lchip_base+loop_pp, 0, DRV_CMD_DP_EN(cmd,index), &pre_br_debug_stats));
                value[4] += GetPreBrDebugStats(V, frQMgrLenErrorCnt_f, &pre_br_debug_stats);
                if(SYS_VCHIP_DUAL_CORE_MODE(lchip))
                {
                    CTC_ERROR_RETURN(DRV_IOCTL(lchip_base+loop_pp, 1, DRV_CMD_DP_EN(cmd,index), &pre_br_debug_stats));
                    value[4] += GetPreBrDebugStats(V, frQMgrLenErrorCnt_f, &pre_br_debug_stats);
                }
            }
            
            if(!(get_detail_en && (user_reason != CTC_DROP_OTHER)))
            {
                cmd = DRV_IOR(EpeScheduleDebugStats_t, DRV_ENTRY_FLAG);
                CTC_ERROR_RETURN(DRV_IOCTL(lchip_base+loop_pp, 0, DRV_CMD_DP_EN(cmd,index), &epe_sch_debug_stats));
                value[5] += GetEpeScheduleDebugStats(V, minPktLenErrorCnt_f, &epe_sch_debug_stats);
                value[6] = value[6] + GetEpeScheduleDebugStats(V, elogAbortedIntf0PktCnt_f, &epe_sch_debug_stats) +
                        GetEpeScheduleDebugStats(V, elogDroppedIntf0PktCnt_f, &epe_sch_debug_stats);
                value[7] += GetEpeScheduleDebugStats(V, txMiscTruncateDropPktCnt_f, &epe_sch_debug_stats);
                value[8] = value[8] + GetEpeScheduleDebugStats(V, frBrDataErrorCnt_f, &epe_sch_debug_stats) +
                        GetEpeScheduleDebugStats(V, frEpeDataErrorCnt_f, &epe_sch_debug_stats);
            }
            
            if(!(get_detail_en && (user_reason != CTC_DROP_NET_RX)))
            {
                cmd = DRV_IOR(NetRxDebugStats_t, DRV_ENTRY_FLAG);
                CTC_ERROR_RETURN(DRV_IOCTL(lchip_base+loop_pp, 0, DRV_CMD_DP_EN(cmd,index),&net_rx_debug_stats));
                value[9] += GetNetRxDebugStats(V, miscRxDataErrCnt_f, &net_rx_debug_stats);
                value[10] = value[10] + GetNetRxDebugStats(V, loop0RxDataErrCnt_f, &net_rx_debug_stats) +
                        GetNetRxDebugStats(V, loop0RxErrDropCnt_f, &net_rx_debug_stats);
                value[11] = value[11] + GetNetRxDebugStats(V, txqm0NetRxErrorCnt_f, &net_rx_debug_stats) +
                        GetNetRxDebugStats(V, txqm1NetRxErrorCnt_f, &net_rx_debug_stats);
                value[12] = value[12] + GetNetRxDebugStats(V, rxBpduDropCnt0_f, &net_rx_debug_stats) +
                        GetNetRxDebugStats(V, rxBpduDropCnt1_f, &net_rx_debug_stats);
                value[13] += GetNetRxDebugStats(V, txErrCnt_f, &net_rx_debug_stats);
                value[14] += GetNetRxDebugStats(V, pauseFrameDiscardCnt_f, &net_rx_debug_stats);
                value[15] += GetNetRxDebugStats(V, loop0MissSopFindCnt_f, &net_rx_debug_stats);
                value[16] += GetNetRxDebugStats(V, loop0MissEopFindCnt_f, &net_rx_debug_stats);
                value[17] += GetNetRxDebugStats(V, loop0ValidBytesErrorCnt_f, &net_rx_debug_stats);
                value[18] += GetNetRxDebugStats(V, miscPktMissSopFindCnt_f, &net_rx_debug_stats);
                value[19] += GetNetRxDebugStats(V, miscPktMissEopFindCnt_f, &net_rx_debug_stats);
                value[20] += GetNetRxDebugStats(V, miscPktValidBytesErrorCnt_f, &net_rx_debug_stats);
                value[21] += GetNetRxDebugStats(V, cpuMacPktLenLess18DropCnt_f, &net_rx_debug_stats);
                value[22] += GetNetRxDebugStats(V, cpuMacAddrDropCnt_f, &net_rx_debug_stats);
                value[24] += GetNetRxDebugStats(V, highPrioDropCnt1_f, &net_rx_debug_stats);
                value[25] += GetNetRxDebugStats(V, midPrioDropCnt1_f, &net_rx_debug_stats);
                value[26] += GetNetRxDebugStats(V, highPrioDropCnt0_f, &net_rx_debug_stats);
                value[27] += GetNetRxDebugStats(V, midPrioDropCnt0_f, &net_rx_debug_stats);
                value[28] += GetNetRxDebugStats(V, netRxLengthChkFailedCnt_f, &net_rx_debug_stats);
                value[29] += GetNetRxDebugStats(V, netRxFullDropTotalCnt_f, &net_rx_debug_stats);
            }
        }
    }
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_NETTX_MIN_LEN, value[0]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_NETTX_NO_BUFFER, value[1]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_NETTX_SOP_EOP, value[2]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_NETTX_TX_ERROR, value[3]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_BSR_BUFRETRV_FROM_QMGR_LEN_ERR, value[4]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_EPE_MIN_PKT_LEN_ERR, value[5]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_EPE_ELOG_ABORTED_PKT, value[6]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_EPE_TRUNCATE_PKT, value[7]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_EPE_DATA_ERR, value[8]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_NETRX_FROM_OTHER, value[9]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_NETRX_FROM_LOOP, value[10]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_NETRX_FROM_NETWORK, value[11]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_NETRX_BPDU_ERROR, value[12]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_NETRX_OUT_ERROR, value[13]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_NETRX_PFC_ERROR, value[14]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_NETRX_LOOP_MISS_SOP, value[15]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_NETRX_LOOP_MISS_EOP, value[16]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_NETRX_LOOP_VALIDBYTE_ERROR, value[17]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_NETRX_MISC_MISS_SOP, value[18]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_NETRX_MISC_MISS_EOP, value[19]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_NETRX_MISC_VALIDBYTE_ERROR, value[20]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_NETRX_MISC_LEN_LESS, value[21]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_NETRX_CPUMAC_CHECK_ERROR, value[22]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_NETRX_TXQM1_HIGHPRIO_DROP, value[24]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_NETRX_TXQM1_MIDPRIO_DROP, value[25]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_NETRX_TXQM0_HIGHPRIO_DROP, value[26]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_NETRX_TXQM0_MIDPRIO_DROP, value[27]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_NETRX_MTULEN_CHECK, value[28]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_NETRX_SOPBUF_FULL_DROP, value[29]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_NETTX_SOP, value[30]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_BSR_IRM_C2C_CHECK_FAIL, value[32]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_BSR_IRM_CRIT_CHECK_FAIL, value[33]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_BSR_IRM_SC_CHECK_FAIL, value[34]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_BSR_IRM_PORT_CHECK_FAIL, value[35]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_BSR_IRM_PORTSC_CHECK_FAIL, value[36]));

    /* OAM feature discard*/
    if(!(get_detail_en && (user_reason != CTC_DROP_TRAFFIC_MANAGER)))
    {
        cmd = DRV_IOR(OamFwdDebugStats_t, OamFwdDebugStats_asicHardDiscardCnt_f);
        CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value[0]));
        CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_BSR_OAM_HW_ERROR, value[0]));
    
        cmd = DRV_IOR(OamFwdDebugStats_t, OamFwdDebugStats_exceptionDiscardCnt_f);
        CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value[0]));
        CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_BSR_OAM_EXCEPTION, value[0]));

        //BSR ENQ feature discard
        cmd = DRV_IOR(QMgrQWriteDebugStats_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &qmgr_qwrite_debug_stats));
        value[0] = GetQMgrQWriteDebugStats(V, cFlexIsolateBlockDiscardCnt_f, &qmgr_qwrite_debug_stats);
        CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_BSR_ENQ_FWD_DROP_CFLEX_ISOLATE_BLOCK, value[0]));
        value[1] = GetQMgrQWriteDebugStats(V, portIsolateBlockDiscardCnt_f, &qmgr_qwrite_debug_stats);
        CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_BSR_ENQ_FWD_DROP_PORT_ISOLATE_BLOCK, value[1]));
        value[2] = GetQMgrQWriteDebugStats(V, rsvChanDropCnt_f, &qmgr_qwrite_debug_stats);
        CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_BSR_ENQ_FWD_DROP_RSV_CHAN_DROP, value[2]));
        value[3] = GetQMgrQWriteDebugStats(V, fromFabricToIloopChannelDropCnt_f, &qmgr_qwrite_debug_stats);
        CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_BSR_QWRITE_FABRIC_TO_ILOOP, value[3]));
        value[4] = GetQMgrQWriteDebugStats(V, frMetDiscardDropCnt_f, &qmgr_qwrite_debug_stats);
        CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_BSR_QWRITE_DROP_FROM_MET, value[4]));

        cmd = DRV_IOR(BufStoreMcCtlSliceDebugStats_t, BufStoreMcCtlSliceDebugStats_mrmDropCnt_f);
        CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value[0]));
        CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_BSR_MRM_ERROR, value[0]));

        cmd = DRV_IOR(QMgrErmDebugStats0_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &qmgr_erm_stats0));
        cmd = DRV_IOR(QMgrErmDebugStats1_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &qmgr_erm_stats1));
        cmd = DRV_IOR(QMgrErmDebugStats2_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &qmgr_erm_stats2));
        cmd = DRV_IOR(QMgrErmDebugStats3_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &qmgr_erm_stats3));
        value[0] = GetQMgrErmDebugStats0(V, frEnqFwdDropCnt_f, &qmgr_erm_stats0) + 
                GetQMgrErmDebugStats1(V, frEnqFwdDropCnt_f, &qmgr_erm_stats1) + 
                GetQMgrErmDebugStats2(V, frEnqFwdDropCnt_f, &qmgr_erm_stats2) + 
                GetQMgrErmDebugStats3(V, frEnqFwdDropCnt_f, &qmgr_erm_stats3);
        CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_BSR_ERM_FWD_DROP, value[0]));
        value[1] = GetQMgrErmDebugStats0(V, resrcChkCriticalDropCnt_f, &qmgr_erm_stats0) + 
                GetQMgrErmDebugStats1(V, resrcChkCriticalDropCnt_f, &qmgr_erm_stats1) + 
                GetQMgrErmDebugStats2(V, resrcChkCriticalDropCnt_f, &qmgr_erm_stats2) + 
                GetQMgrErmDebugStats3(V, resrcChkCriticalDropCnt_f, &qmgr_erm_stats3);
        CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_BSR_ERM_CRIT_CHECK_FAIL, value[1]));
        value[2] = GetQMgrErmDebugStats0(V, resrcChkTotalDropCnt_f, &qmgr_erm_stats0) + 
                GetQMgrErmDebugStats1(V, resrcChkTotalDropCnt_f, &qmgr_erm_stats1) + 
                GetQMgrErmDebugStats2(V, resrcChkTotalDropCnt_f, &qmgr_erm_stats2) + 
                GetQMgrErmDebugStats3(V, resrcChkTotalDropCnt_f, &qmgr_erm_stats3);
        CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_BSR_ERM_TOTAL_CHECK_FAIL, value[2]));
        value[3] = GetQMgrErmDebugStats0(V, resrcChkScDropCnt_f, &qmgr_erm_stats0) + 
                GetQMgrErmDebugStats1(V, resrcChkScDropCnt_f, &qmgr_erm_stats1) + 
                GetQMgrErmDebugStats2(V, resrcChkScDropCnt_f, &qmgr_erm_stats2) + 
                GetQMgrErmDebugStats3(V, resrcChkScDropCnt_f, &qmgr_erm_stats3);
        CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_BSR_ERM_SC_CHECK_FAIL, value[3]));
        value[4] = GetQMgrErmDebugStats0(V, resrcChkPortScDropCnt_f, &qmgr_erm_stats0) + 
                GetQMgrErmDebugStats1(V, resrcChkPortScDropCnt_f, &qmgr_erm_stats1) + 
                GetQMgrErmDebugStats2(V, resrcChkPortScDropCnt_f, &qmgr_erm_stats2) + 
                GetQMgrErmDebugStats3(V, resrcChkPortScDropCnt_f, &qmgr_erm_stats3);
        CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_BSR_ERM_PORTSC_CHECK_FAIL, value[4]));
        value[5] = GetQMgrErmDebugStats0(V, resrcChkPortDropCnt_f, &qmgr_erm_stats0) + 
                GetQMgrErmDebugStats1(V, resrcChkPortDropCnt_f, &qmgr_erm_stats1) + 
                GetQMgrErmDebugStats2(V, resrcChkPortDropCnt_f, &qmgr_erm_stats2) + 
                GetQMgrErmDebugStats3(V, resrcChkPortDropCnt_f, &qmgr_erm_stats3);
        CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_BSR_ERM_PORT_CHECK_FAIL, value[5]));
        value[6] = GetQMgrErmDebugStats0(V, resrcChkQueueDropCnt_f, &qmgr_erm_stats0) + 
                GetQMgrErmDebugStats1(V, resrcChkQueueDropCnt_f, &qmgr_erm_stats1) + 
                GetQMgrErmDebugStats2(V, resrcChkQueueDropCnt_f, &qmgr_erm_stats2) + 
                GetQMgrErmDebugStats3(V, resrcChkQueueDropCnt_f, &qmgr_erm_stats3);
        CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_BSR_ERM_QUEUE_CHECK_FAIL, value[6]));
        value[7] = GetQMgrErmDebugStats0(V, resrcChkC2cDropCnt_f, &qmgr_erm_stats0) + 
                GetQMgrErmDebugStats1(V, resrcChkC2cDropCnt_f, &qmgr_erm_stats1) + 
                GetQMgrErmDebugStats2(V, resrcChkC2cDropCnt_f, &qmgr_erm_stats2) + 
                GetQMgrErmDebugStats3(V, resrcChkC2cDropCnt_f, &qmgr_erm_stats3);
        CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_BSR_ERM_C2C_CHECK_FAIL, value[7]));
        value[8] = GetQMgrErmDebugStats0(V, ermDropMsgCnt_f, &qmgr_erm_stats0) + 
                GetQMgrErmDebugStats1(V, ermDropMsgCnt_f, &qmgr_erm_stats1) + 
                GetQMgrErmDebugStats2(V, ermDropMsgCnt_f, &qmgr_erm_stats2) + 
                GetQMgrErmDebugStats3(V, ermDropMsgCnt_f, &qmgr_erm_stats3);
        CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_BSR_ERM_CHECK_FAIL, value[8]));
    }

//EPE feature discard
    if(!(get_detail_en && (user_reason != CTC_DROP_OTHER)))
    {
        cmd = DRV_IOR(EpeHdrProcDebugStats_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &epe_hdr_proc_debug_stats));
        value[0] = GetEpeHdrProcDebugStats(V, l2EditHardErrorCnt_f, &epe_hdr_proc_debug_stats);
        CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_BSR_EPE_HW_L2_EDIT, value[0]));

        value[0] = GetEpeHdrProcDebugStats(V, l3EditHardErrorCnt_f, &epe_hdr_proc_debug_stats);
        CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_BSR_EPE_HW_L3_EDIT, value[0]));

        value[0] = GetEpeHdrProcDebugStats(V, innerL2HardErrorCnt_f, &epe_hdr_proc_debug_stats);
        CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_BSR_EPE_HW_INNER_L2, value[0]));

        value[0] = GetEpeHdrProcDebugStats(V, payloadHardErrorCnt_f, &epe_hdr_proc_debug_stats);
        CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_BSR_EPE_HW_PAYLOAD, value[0]));

        value[0] = GetEpeHdrProcDebugStats(V, payloadDiscardCnt_f, &epe_hdr_proc_debug_stats);
        CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_BSR_EPE_PAYLOAD, value[0]));
        
        value[0] = GetEpeHdrProcDebugStats(V, l2EditDiscardCnt_f, &epe_hdr_proc_debug_stats);
        CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_BSR_EPE_L2_EDIT, value[0]));

        value[0] = GetEpeHdrProcDebugStats(V, l3EditDiscardCnt_f, &epe_hdr_proc_debug_stats);
        CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_BSR_EPE_L3_EDIT, value[0]));

        value[0] = GetEpeHdrProcDebugStats(V, innerL2DiscardCnt_f, &epe_hdr_proc_debug_stats);
        CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_BSR_EPE_INNER_L2, value[0]));

        value[0] = GetEpeHdrProcDebugStats(V, xEditDiscardCnt_f, &epe_hdr_proc_debug_stats);
        CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_BSR_EPE_HW_XEDIT, value[0]));

        value[0] = GetEpeHdrProcDebugStats(V, xEditHardErrorCnt_f, &epe_hdr_proc_debug_stats);
        CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_AT_DISCARD_BSR_EPE_XEDIT, value[0]));
    }
    return CTC_E_NONE;
}

#define ______DIAG_MCHIP_API______

int32
_sys_at_diag_bist_sram(uint8 lchip, uint8* err_mem_id)
{
    int32 ret = CTC_E_NONE;
    uint32 cmd = 0;
    uint32 field_val = 0;
    uint32 done = 0;
    uint8  wait_cnt = 0;
    uint8  pp_base = SYS_PP_BASE(lchip);
    BistGoCfg_m bistgo_cfg;
    BistTestEnCfg_m bist_en_cfg;

    if (lchip != pp_base && lchip != (pp_base + SYS_CORE_PP_NUM(lchip)))
    {
        return ret;
    }
    cmd = DRV_IOW(SupIntrCtl_t, SupIntrCtl_interruptEn_f);
    DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &field_val);

    sal_memset(&bist_en_cfg, 0 , sizeof(BistTestEnCfg_m));
    SetBistTestEnCfg(V, bistTestEnCtcMisc_f, &bist_en_cfg, 1);
    cmd = DRV_IOW(BistTestEnCfg_t, DRV_ENTRY_FLAG);
    DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &bist_en_cfg);

    sal_memset(&bistgo_cfg, 0 , sizeof(BistGoCfg_m));
    cmd = DRV_IOW(BistGoCfg_t, DRV_ENTRY_FLAG);
    DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &bistgo_cfg);

    SetBistGoCfg(V, bistGoCtcMisc_f, &bistgo_cfg, 1);
    cmd = DRV_IOW(BistGoCfg_t, DRV_ENTRY_FLAG);
    DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &bistgo_cfg);

    cmd = DRV_IOR(BistDoneMon_t, BistDoneMon_bistDoneCtcMisc_f);
    while (1)
    {
        DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &done);
        if (done)
        {
            cmd = DRV_IOR(BistPassMon_t, BistPassMon_bistPassCtcMisc_f);
            DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &field_val);
            *err_mem_id = 0;
            if(!field_val)
            {
               *err_mem_id = 0xff;
            }
            ret = CTC_E_NONE;
            break;
        }
        else
        {
            wait_cnt++;
            if (50 == wait_cnt)
            {
                *err_mem_id = 0xff;
                SYS_DIAG_DBG_OUT(CTC_DEBUG_LEVEL_ERROR, "SRAM BIST OUT OF TIME!\n");
                ret = CTC_E_HW_TIME_OUT;
                break;
            }
            sal_task_sleep(1);
        }
    }

    sal_memset(&bistgo_cfg, 0 , sizeof(BistGoCfg_m));
    cmd = DRV_IOW(BistGoCfg_t, DRV_ENTRY_FLAG);
    DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &bistgo_cfg);
    sal_memset(&bist_en_cfg, 0 , sizeof(BistTestEnCfg_m));
    cmd = DRV_IOW(BistTestEnCfg_t, DRV_ENTRY_FLAG);
    DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &bist_en_cfg);

    return ret;
}

int32
sys_at_diag_get_pkt_trace(uint8 lchip, void* p_value, uint8 position)
{
    ctc_diag_pkt_trace_result_t* p_rslt = (ctc_diag_pkt_trace_result_t*)p_value;

    CTC_PTR_VALID_CHECK(p_rslt);
    p_usw_diag_master[lchip]->cur_discard_type_map = 0;
    p_usw_diag_master[lchip]->cur_exception_map = 0;

    switch (position)
    {
        case CTC_DIAG_TRACE_POS_IPE:
            CTC_ERROR_RETURN(_sys_at_diag_get_pkt_trace_pos_ipe(lchip, p_rslt));
            break;
        case CTC_DIAG_TRACE_POS_TM:
            CTC_ERROR_RETURN(_sys_at_diag_get_pkt_trace_pos_tm(lchip, p_rslt));
            break;
        case CTC_DIAG_TRACE_POS_EPE:
            CTC_ERROR_RETURN(_sys_at_diag_get_pkt_trace_pos_epe(lchip, p_rslt));
            break;
        case CTC_DIAG_TRACE_POS_OAM:
            CTC_ERROR_RETURN(_sys_at_diag_get_pkt_trace_pos_oam(lchip, p_rslt));
            break;
        default:
            break;
    }
    return CTC_E_NONE;
}

int32
sys_at_diag_get_drop_info(uint8 lchip, void* p_value)
{
    ctc_diag_drop_t* p_drop = (ctc_diag_drop_t*)p_value;
    CTC_PTR_VALID_CHECK(p_drop);
    CTC_ERROR_RETURN(_sys_at_diag_get_drop_info(lchip, p_drop));
    return CTC_E_NONE;
}

int32
sys_at_diag_get_pos(uint16 discard, uint8* pos)
{
    if (discard >= SYS_AT_DISCARD_NETRX_START && discard <= SYS_AT_DISCARD_NETRX_END)
    {
        *pos = CTC_DIAG_DROP_POS_NETRX;
    }
    else if (discard <= SYS_AT_DISCARD_IPE_END)
    {
        *pos = CTC_DIAG_DROP_POS_IPE;
    }
    else if (discard >= SYS_AT_DISCARD_BSR_START && discard <= SYS_AT_DISCARD_BSR_END)
    {
        *pos = CTC_DIAG_DROP_POS_BSR;
    }
    else if (discard >= SYS_AT_DISCARD_EPE_START && discard <= SYS_AT_DISCARD_EPE_END)
    {
        *pos = CTC_DIAG_DROP_POS_EPE;
    }
    else if (discard >= SYS_AT_DISCARD_NETTX_START && discard <= SYS_AT_DISCARD_NETTX_END)
    {
        *pos = CTC_DIAG_DROP_POS_NETTX;
    }
    else 
    {
        *pos = CTC_DIAG_DROP_POS_OAM;
    }
    return CTC_E_NONE;
}

int32
sys_at_diag_set_dbg_pkt(uint8 lchip, void* p_value)
{
    uint32 cmd = 0;
    uint32 loop = 0;
    uint32 tmp_data = 0;
    uint32 tmp_mask = 0;
    hw_mac_addr_t   hw_mac      = {0};
    ipv6_addr_t     hw_ip6 = {0};
    ctc_field_key_t*  field = NULL;
    ctc_diag_pkt_trace_t* p_trace = (ctc_diag_pkt_trace_t*)p_value;
    IpeUserIdFlowCam_m ds_flow_cam;
    ParserResult_m parser_result;
    ParserResult_m parser_result_mask;

    CTC_PTR_VALID_CHECK(p_trace);
    sal_memset(&ds_flow_cam, 0, sizeof(IpeUserIdFlowCam_m));
    sal_memset(&parser_result, 0, sizeof(ParserResult_m));
    sal_memset(&parser_result_mask, 0, sizeof(ParserResult_m));
    while (loop < p_trace->pkt.network.count)
    {
        field = &(p_trace->pkt.network.field[loop]);
        loop++;
        switch (field->type)
        {
            case CTC_FIELD_KEY_L2_TYPE:
                SetParserResult(V, layer2Type_f, &parser_result, field->data);
                SetParserResult(V, layer2Type_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_L3_TYPE:
                SetParserResult(V, layer3Type_f, &parser_result, field->data);
                SetParserResult(V, layer3Type_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_L4_TYPE:
                SetParserResult(V, layer4Type_f, &parser_result, sys_usw_l4_type_map(lchip, field->data, TRUE));
                SetParserResult(V, layer4Type_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_L4_USER_TYPE:
                SetParserResult(V, layer4UserType_f, &parser_result, sys_usw_l4_user_type_map(lchip, field->data, 1));
                SetParserResult(V, layer4UserType_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_ETHER_TYPE:
                SetParserResult(V, etherType_f, &parser_result, field->data);
                SetParserResult(V, etherType_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_MAC_DA:
                CTC_PTR_VALID_CHECK(field->ext_data);
                CTC_PTR_VALID_CHECK(field->ext_mask);
                SYS_USW_SET_HW_MAC(hw_mac, (uint8*)field->ext_data);
                SetParserResult(A, macDa_f, &parser_result, hw_mac);
                SYS_USW_SET_HW_MAC(hw_mac, (uint8*)field->ext_mask);
                SetParserResult(A, macDa_f, &parser_result_mask, hw_mac);
                break;
            case CTC_FIELD_KEY_MAC_SA:
                CTC_PTR_VALID_CHECK(field->ext_data);
                CTC_PTR_VALID_CHECK(field->ext_mask);
                SYS_USW_SET_HW_MAC(hw_mac, (uint8*)field->ext_data);
                SetParserResult(A, macSa_f, &parser_result, hw_mac);
                SYS_USW_SET_HW_MAC(hw_mac, (uint8*)field->ext_mask);
                SetParserResult(A, macSa_f, &parser_result_mask, hw_mac);
                break;
            case CTC_FIELD_KEY_SVLAN_ID:
                SetParserResult(V, svlanId_f, &parser_result, field->data);
                SetParserResult(V, svlanId_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_CVLAN_ID:
                SetParserResult(V, cvlanId_f, &parser_result, field->data);
                SetParserResult(V, cvlanId_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_VLAN_NUM:
                SetParserResult(V, vlanNum_f, &parser_result, field->data);
                SetParserResult(V, vlanNum_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_IP_SA:
                SetParserResult(V, uL3Source_gIpv4_ipSa_f, &parser_result, field->data);
                SetParserResult(V, uL3Source_gIpv4_ipSa_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_IP_DA:
                SetParserResult(V, uL3Dest_gIpv4_ipDa_f, &parser_result, field->data);
                SetParserResult(V, uL3Dest_gIpv4_ipDa_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_IPV6_SA:
                CTC_PTR_VALID_CHECK(field->ext_data);
                CTC_PTR_VALID_CHECK(field->ext_mask);
                SYS_USW_REVERT_IP6(hw_ip6, (uint32*)field->ext_data);
                SetParserResult(A, uL3Source_gIpv6_ipSa_f, &parser_result, hw_ip6);
                SYS_USW_REVERT_IP6(hw_ip6, (uint32*)field->ext_mask);
                SetParserResult(A, uL3Source_gIpv6_ipSa_f, &parser_result_mask, hw_ip6);
                break;
            case CTC_FIELD_KEY_IPV6_DA:
                CTC_PTR_VALID_CHECK(field->ext_data);
                CTC_PTR_VALID_CHECK(field->ext_mask);
                SYS_USW_REVERT_IP6(hw_ip6, (uint32*)field->ext_data);
                SetParserResult(A, uL3Dest_gIpv6_ipDa_f, &parser_result, hw_ip6);
                SYS_USW_REVERT_IP6(hw_ip6, (uint32*)field->ext_mask);
                SetParserResult(A, uL3Dest_gIpv6_ipDa_f, &parser_result_mask, hw_ip6);
                break;
            case CTC_FIELD_KEY_IPV6_FLOW_LABEL:
                SetParserResult(V, ipv6FlowLabel_f, &parser_result, field->data);
                SetParserResult(V, ipv6FlowLabel_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_IP_PROTOCOL:
                SetParserResult(V, layer3HeaderProtocol_f, &parser_result, field->data);
                SetParserResult(V, layer3HeaderProtocol_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_IP_TTL:
                SetParserResult(V, ttl_f, &parser_result, field->data);
                SetParserResult(V, ttl_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_ARP_OP_CODE:
                SetParserResult(V, uL3Dest_gArp_arpOpCode_f, &parser_result, field->data);
                SetParserResult(V, uL3Dest_gArp_arpOpCode_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_ARP_PROTOCOL_TYPE:
                SetParserResult(V, uL3Source_gArp_protocolType_f, &parser_result, field->data);
                SetParserResult(V, uL3Source_gArp_protocolType_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_ARP_SENDER_IP:
                SetParserResult(V, uL3Source_gArp_senderIp_f, &parser_result, field->data);
                SetParserResult(V, uL3Source_gArp_senderIp_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_ARP_TARGET_IP:
                SetParserResult(V, uL3Dest_gArp_targetIp_f, &parser_result, field->data);
                SetParserResult(V, uL3Dest_gArp_targetIp_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_SENDER_MAC:
                CTC_PTR_VALID_CHECK(field->ext_data);
                CTC_PTR_VALID_CHECK(field->ext_mask);
                SYS_USW_SET_HW_MAC(hw_mac, (uint8*)field->ext_data);
                SetParserResult(A, uL3Source_gArp_senderMac_f, &parser_result, hw_mac);
                SYS_USW_SET_HW_MAC(hw_mac, (uint8*)field->ext_mask);
                SetParserResult(A, uL3Source_gArp_senderMac_f, &parser_result_mask, hw_mac);
                break;
            case CTC_FIELD_KEY_TARGET_MAC:
                CTC_PTR_VALID_CHECK(field->ext_data);
                CTC_PTR_VALID_CHECK(field->ext_mask);
                SYS_USW_SET_HW_MAC(hw_mac, (uint8*)field->ext_data);
                SetParserResult(A, uL3Dest_gArp_targetMac_f, &parser_result, hw_mac);
                SYS_USW_SET_HW_MAC(hw_mac, (uint8*)field->ext_mask);
                SetParserResult(A, uL3Dest_gArp_targetMac_f, &parser_result_mask, hw_mac);
                break;
            case CTC_FIELD_KEY_ETHER_OAM_LEVEL:
                SetParserResult(V, uL3Dest_gEtherOam_etherOamLevel_f, &parser_result, field->data);
                SetParserResult(V, uL3Dest_gEtherOam_etherOamLevel_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_ETHER_OAM_OP_CODE:
                SetParserResult(V, uL3Dest_gEtherOam_etherOamOpCode_f, &parser_result, field->data);
                SetParserResult(V, uL3Dest_gEtherOam_etherOamOpCode_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_ETHER_OAM_VERSION:
                SetParserResult(V, uL3Dest_gEtherOam_etherOamVersion_f, &parser_result, field->data);
                SetParserResult(V, uL3Dest_gEtherOam_etherOamVersion_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_FCOE_DST_FCID:
                SetParserResult(V, uL3Dest_gFcoe_fcoeDid_f, &parser_result, field->data);
                SetParserResult(V, uL3Dest_gFcoe_fcoeDid_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_FCOE_SRC_FCID:
                SetParserResult(V, uL3Source_gFcoe_fcoeSid_f, &parser_result, field->data);
                SetParserResult(V, uL3Source_gFcoe_fcoeSid_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_LABEL_NUM:
                SetParserResult(V, uL3Tos_gMpls_labelNum_f, &parser_result, field->data);
                SetParserResult(V, uL3Tos_gMpls_labelNum_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_MPLS_LABEL0:
                tmp_data =  GetParserResult(V, uL3Dest_gMpls_mplsLabel0_f, &parser_result);
                tmp_mask = GetParserResult(V, uL3Dest_gMpls_mplsLabel0_f, &parser_result_mask);
                SetParserResult(V, uL3Dest_gMpls_mplsLabel0_f, &parser_result, ((field->data&0xFFFFF) << 12)|(tmp_data&0xFFF));
                SetParserResult(V, uL3Dest_gMpls_mplsLabel0_f, &parser_result_mask, ((field->mask&0xFFFFF) << 12)|(tmp_mask&0xFFF));
                break;
            case CTC_FIELD_KEY_MPLS_EXP0:
                tmp_data =  GetParserResult(V, uL3Dest_gMpls_mplsLabel0_f, &parser_result);
                tmp_mask = GetParserResult(V, uL3Dest_gMpls_mplsLabel0_f, &parser_result_mask);
                SetParserResult(V, uL3Dest_gMpls_mplsLabel0_f, &parser_result, ((field->data& 0x7) << 9)|(tmp_data&0xFFFFF1FF));
                SetParserResult(V, uL3Dest_gMpls_mplsLabel0_f, &parser_result_mask, ((field->mask & 0x7) << 9)|(tmp_mask&0xFFFFF1FF));
                break;
            case CTC_FIELD_KEY_MPLS_SBIT0:
                tmp_data =  GetParserResult(V, uL3Dest_gMpls_mplsLabel0_f, &parser_result);
                tmp_mask = GetParserResult(V, uL3Dest_gMpls_mplsLabel0_f, &parser_result_mask);
                SetParserResult(V, uL3Dest_gMpls_mplsLabel0_f, &parser_result, ((field->data & 0x1) << 8)|(tmp_data&0xFFFFFEFF));
                SetParserResult(V, uL3Dest_gMpls_mplsLabel0_f, &parser_result_mask, ((field->mask & 0x1) << 8)|(tmp_mask&0xFFFFFEFF));
                break;
            case CTC_FIELD_KEY_MPLS_TTL0:
                tmp_data =  GetParserResult(V, uL3Dest_gMpls_mplsLabel0_f, &parser_result);
                tmp_mask = GetParserResult(V, uL3Dest_gMpls_mplsLabel0_f, &parser_result_mask);
                SetParserResult(V, uL3Dest_gMpls_mplsLabel0_f, &parser_result, (field->data &0xFF)|(tmp_data&0xFFFFFF00));
                SetParserResult(V, uL3Dest_gMpls_mplsLabel0_f, &parser_result_mask, (field->mask &0xFF)|(tmp_mask&0xFFFFFF00));
                break;
            case CTC_FIELD_KEY_MPLS_LABEL1:
                tmp_data =  GetParserResult(V, uL3Dest_gMpls_mplsLabel1_f, &parser_result);
                tmp_mask = GetParserResult(V, uL3Dest_gMpls_mplsLabel1_f, &parser_result_mask);
                SetParserResult(V, uL3Dest_gMpls_mplsLabel1_f, &parser_result, ((field->data&0xFFFFF) << 12) | (tmp_data&0xFFF));
                SetParserResult(V, uL3Dest_gMpls_mplsLabel1_f, &parser_result_mask, ((field->mask&0xFFFFF) << 12) | (tmp_mask&0xFFF));
                break;
            case CTC_FIELD_KEY_MPLS_EXP1:
                tmp_data =  GetParserResult(V, uL3Dest_gMpls_mplsLabel1_f, &parser_result);
                tmp_mask = GetParserResult(V, uL3Dest_gMpls_mplsLabel1_f, &parser_result_mask);
                SetParserResult(V, uL3Dest_gMpls_mplsLabel1_f, &parser_result, ((field->data& 0x7) << 9)  | (tmp_data&0xFFFFF1FF));
                SetParserResult(V, uL3Dest_gMpls_mplsLabel1_f, &parser_result_mask, ((field->mask & 0x7) << 9) | (tmp_mask&0xFFFFF1FF));
                break;
            case CTC_FIELD_KEY_MPLS_SBIT1:
                tmp_data =  GetParserResult(V, uL3Dest_gMpls_mplsLabel1_f, &parser_result);
                tmp_mask = GetParserResult(V, uL3Dest_gMpls_mplsLabel1_f, &parser_result_mask);
                SetParserResult(V, uL3Dest_gMpls_mplsLabel1_f, &parser_result, ((field->data & 0x1) << 8)| (tmp_data&0xFFFFFEFF));
                SetParserResult(V, uL3Dest_gMpls_mplsLabel1_f, &parser_result_mask, ((field->mask & 0x1) << 8) | (tmp_mask&0xFFFFFEFF));
                break;
            case CTC_FIELD_KEY_MPLS_TTL1:
                tmp_data =  GetParserResult(V, uL3Dest_gMpls_mplsLabel1_f, &parser_result);
                tmp_mask = GetParserResult(V, uL3Dest_gMpls_mplsLabel1_f, &parser_result_mask);
                SetParserResult(V, uL3Dest_gMpls_mplsLabel1_f, &parser_result, (field->data &0xFF) | (tmp_data&0xFFFFFF00));
                SetParserResult(V, uL3Dest_gMpls_mplsLabel1_f, &parser_result_mask, (field->mask &0xFF) | (tmp_mask&0xFFFFFF00));
                break;
            case CTC_FIELD_KEY_MPLS_LABEL2:
                tmp_data =  GetParserResult(V, uL3Dest_gMpls_mplsLabel2_f, &parser_result);
                tmp_mask = GetParserResult(V, uL3Dest_gMpls_mplsLabel2_f, &parser_result_mask);
                SetParserResult(V, uL3Dest_gMpls_mplsLabel2_f, &parser_result, ((field->data&0xFFFFF) << 12) | (tmp_data&0xFFF));
                SetParserResult(V, uL3Dest_gMpls_mplsLabel2_f, &parser_result_mask, ((field->mask&0xFFFFF) << 12) | (tmp_mask&0xFFF));
                break;
            case CTC_FIELD_KEY_MPLS_EXP2:
                tmp_data =  GetParserResult(V, uL3Dest_gMpls_mplsLabel2_f, &parser_result);
                tmp_mask = GetParserResult(V, uL3Dest_gMpls_mplsLabel2_f, &parser_result_mask);
                SetParserResult(V, uL3Dest_gMpls_mplsLabel2_f, &parser_result, ((field->data& 0x7) << 9)  | (tmp_data&0xFFFFF1FF));
                SetParserResult(V, uL3Dest_gMpls_mplsLabel2_f, &parser_result_mask, ((field->mask & 0x7) << 9) | (tmp_mask&0xFFFFF1FF));
                break;
            case CTC_FIELD_KEY_MPLS_SBIT2:
                tmp_data =  GetParserResult(V, uL3Dest_gMpls_mplsLabel2_f, &parser_result);
                tmp_mask = GetParserResult(V, uL3Dest_gMpls_mplsLabel2_f, &parser_result_mask);
                SetParserResult(V, uL3Dest_gMpls_mplsLabel2_f, &parser_result, ((field->data & 0x1) << 8)| (tmp_data&0xFFFFFEFF));
                SetParserResult(V, uL3Dest_gMpls_mplsLabel2_f, &parser_result_mask, ((field->mask & 0x1) << 8) | (tmp_mask&0xFFFFFEFF));
                break;
            case CTC_FIELD_KEY_MPLS_TTL2:
                tmp_data =  GetParserResult(V, uL3Dest_gMpls_mplsLabel2_f, &parser_result);
                tmp_mask = GetParserResult(V, uL3Dest_gMpls_mplsLabel2_f, &parser_result_mask);
                SetParserResult(V, uL3Dest_gMpls_mplsLabel2_f, &parser_result, (field->data &0xFF) | (tmp_data&0xFFFFFF00));
                SetParserResult(V, uL3Dest_gMpls_mplsLabel2_f, &parser_result_mask, (field->mask &0xFF) | (tmp_mask&0xFFFFFF00));
                break;
            case CTC_FIELD_KEY_SLOW_PROTOCOL_CODE:
                SetParserResult(V, uL3Dest_gSlowProto_slowProtocolCode_f, &parser_result, field->data);
                SetParserResult(V, uL3Dest_gSlowProto_slowProtocolCode_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_SLOW_PROTOCOL_FLAGS:
                SetParserResult(V, uL3Dest_gSlowProto_slowProtocolFlags_f, &parser_result, field->data);
                SetParserResult(V, uL3Dest_gSlowProto_slowProtocolFlags_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_SLOW_PROTOCOL_SUB_TYPE:
                SetParserResult(V, uL3Dest_gSlowProto_slowProtocolSubType_f, &parser_result, field->data);
                SetParserResult(V, uL3Dest_gSlowProto_slowProtocolSubType_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_INGRESS_NICKNAME:
                SetParserResult(V, uL3Source_gTrill_ingressNickname_f, &parser_result, field->data);
                SetParserResult(V, uL3Source_gTrill_ingressNickname_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_EGRESS_NICKNAME:
                SetParserResult(V, uL3Dest_gTrill_egressNickname_f, &parser_result, field->data);
                SetParserResult(V, uL3Dest_gTrill_egressNickname_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_TRILL_INNER_VLANID:
                SetParserResult(V, uL3Dest_gTrill_trillInnerVlanId_f, &parser_result, field->data);
                SetParserResult(V, uL3Dest_gTrill_trillInnerVlanId_f, &parser_result_mask, field->mask);
                SetParserResult(V, uL3Dest_gTrill_trillInnerVlanValid_f, &parser_result, 1);
                SetParserResult(V, uL3Dest_gTrill_trillInnerVlanValid_f, &parser_result_mask, 1);
                break;
            case CTC_FIELD_KEY_TRILL_VERSION:
                SetParserResult(V, uL3Dest_gTrill_trillVersion_f, &parser_result, field->data);
                SetParserResult(V, uL3Dest_gTrill_trillVersion_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_L4_DST_PORT:
                SetParserResult(V, uL4Dest_gPort_l4DestPort_f, &parser_result, field->data);
                SetParserResult(V, uL4Dest_gPort_l4DestPort_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_L4_SRC_PORT:
                SetParserResult(V, uL4Source_gPort_l4SourcePort_f, &parser_result, field->data);
                SetParserResult(V, uL4Source_gPort_l4SourcePort_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_TCP_ECN:
                SetParserResult(V, uL4UserData_gTcp_tcpEcn_f, &parser_result, field->data);
                SetParserResult(V, uL4UserData_gTcp_tcpEcn_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_TCP_FLAGS:
                SetParserResult(V, uL4UserData_gTcp_tcpFlags_f, &parser_result, field->data);
                SetParserResult(V, uL4UserData_gTcp_tcpFlags_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_VN_ID:
                SetParserResult(V, uL4UserData_gVxlan_vxlanVni_f, &parser_result, field->data);
                SetParserResult(V, uL4UserData_gVxlan_vxlanVni_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_VXLAN_FLAGS:
                SetParserResult(V, uL4UserData_gVxlan_vxlanFlags_f, &parser_result, field->data);
                SetParserResult(V, uL4UserData_gVxlan_vxlanFlags_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_VXLAN_RSV1:
                SetParserResult(V, uL4UserData_gVxlan_vxlanReserved1_f, &parser_result, field->data);
                SetParserResult(V, uL4UserData_gVxlan_vxlanReserved1_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_VXLAN_RSV2:
                SetParserResult(V, uL4UserData_gVxlan_vxlanReserved2_f, &parser_result, field->data);
                SetParserResult(V, uL4UserData_gVxlan_vxlanReserved2_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_GRE_KEY:
                SetParserResult(V, uL4UserData_gGre_greKey_f, &parser_result, field->data);
                SetParserResult(V, uL4UserData_gGre_greKey_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_GRE_FLAGS:
                SetParserResult(V, uL4Source_gGre_greFlags_f, &parser_result, field->data);
                SetParserResult(V, uL4Source_gGre_greFlags_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_GRE_PROTOCOL_TYPE:
                SetParserResult(V, uL4Dest_gGre_greProtocolType_f, &parser_result, field->data);
                SetParserResult(V, uL4Dest_gGre_greProtocolType_f, &parser_result_mask, field->mask);
                break;
            default:
                return CTC_E_NOT_SUPPORT;
        }
    }
    cmd = DRV_IOW(IpeUserIdFlowCam_t, DRV_ENTRY_FLAG);
    SetIpeUserIdFlowCam(A, g_0_data_f, &ds_flow_cam, &parser_result);
    SetIpeUserIdFlowCam(A, g_1_data_f, &ds_flow_cam, &parser_result_mask);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &ds_flow_cam));

    return CTC_E_NONE;
}

int32
sys_at_diag_set_dbg_session(uint8 lchip, void* p_value)
{
    uint8 loop_i;
    uint8 type_pp_bmp = 0;
    uint8 step = DsMetFifoDebugPathSel_g_1_debugPathSel_f - DsMetFifoDebugPathSel_g_0_debugPathSel_f;
    uint32 value = 0;
    uint32 cmd = 0;
    uint32 dest_map = 0;
    uint32 watch_point = 0;
    uint8 io_valid1 = 0;
    uint8 io_valid2 = 0;
    ctc_diag_pkt_trace_t* p_trace = (ctc_diag_pkt_trace_t*)p_value;
    ctc_diag_trace_watch_key_t* watch_key = NULL;
    IpeUserIdFlowCam_m ds_flow_cam;
    BufStoreDebugCam_m ds_buff_store_cam;
    MetFifoDebugCam_m ds_met_fifo_cam;
    EpeHdrAdjustDebugCam_m ds_epe_dbg_cam;
    DsMetFifoDebugPathSel_m ds_met_fifo_sel;
    ds1_t xdata_ctl;

    CTC_PTR_VALID_CHECK(p_trace);
    sal_memset(&ds_buff_store_cam, 0, sizeof(BufStoreDebugCam_m));
    sal_memset(&ds_met_fifo_cam, 0, sizeof(MetFifoDebugCam_m));
    sal_memset(&ds_epe_dbg_cam, 0, sizeof(EpeHdrAdjustDebugCam_m));
    sal_memset(&ds_met_fifo_sel, 0, sizeof(DsMetFifoDebugPathSel_m));
    sal_memset(&xdata_ctl, 0, sizeof(ds_t));

    CTC_MAX_VALUE_CHECK(p_trace->watch_point, CTC_DIAG_TRACE_POINT_MAX - 1);
    watch_point = p_trace->watch_point;
    watch_key = &p_trace->watch_key;
    CTC_BIT_SET(type_pp_bmp, watch_point);

    cmd = DRV_IOR(IpeUserIdFlowCam_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &ds_flow_cam));

    /* MetFif select isDbgPkt */
    value = 1;
    for (loop_i = 0; loop_i < 16; loop_i ++)
    {
        SetDsMetFifoDebugPathSel(V,g_0_debugPathSel_f + step*loop_i,&ds_met_fifo_sel,value);
    }

    for (loop_i = 0; loop_i < 32; loop_i ++)
    {
        cmd = DRV_IOW(DsMetFifoDebugPathSel_t, DRV_ENTRY_FLAG);
        DRV_IOCTL(lchip, loop_i, DIAG_PP_EN(cmd, type_pp_bmp, CTC_DIAG_TRACE_POINT_TM_MET), &ds_met_fifo_sel);
    }

    value = (watch_point == CTC_DIAG_TRACE_POINT_IPE_SCL) ? 0 : 1;
    cmd = DRV_IOW(IpeUserIdFlowLoopCam_t, IpeUserIdFlowLoopCam_isDebuggedPktMask_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &value));
    cmd = DRV_IOW(IpeUserIdFlowCtl_t, IpeUserIdFlowCtl_debugMode_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &value));

    switch (watch_point)
    {
        case CTC_DIAG_TRACE_POINT_IPE_SCL:
            if (CTC_BMP_ISSET(watch_key->key_mask_bmp, CTC_DIAG_WATCH_KEY_MASK_XDATA))
            {
                cmd = DRV_IOR(IpeUserIdXCtl_t, DRV_ENTRY_FLAG);
                CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &xdata_ctl));
                SetIpeUserIdXCtl(V, gDebug_0_nibbleSel_f, &xdata_ctl, watch_key->xdata->fields[0].offset/CTC_XDATA_WIDTH_4);
                cmd = DRV_IOW(IpeUserIdXCtl_t, DRV_ENTRY_FLAG);
                CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &xdata_ctl));

                SetIpeUserIdFlowCam(V, g_0_auxData_f, &ds_flow_cam, watch_key->xdata->fields[0].data);
                SetIpeUserIdFlowCam(V, g_1_auxData_f, &ds_flow_cam, watch_key->xdata->fields[0].mask);
            }
            if (CTC_BMP_ISSET(watch_key->key_mask_bmp, CTC_DIAG_WATCH_KEY_MASK_SRC_LPORT))
            {
                SetIpeUserIdFlowCam(V, g_0_localPhyPort_f, &ds_flow_cam, watch_key->src_lport);
                SetIpeUserIdFlowCam(V, g_1_localPhyPort_f, &ds_flow_cam, 0x1FF);
            }
            if (CTC_BMP_ISSET(watch_key->key_mask_bmp, CTC_DIAG_WATCH_KEY_MASK_CHANNEL))
            {
                SetIpeUserIdFlowCam(V, g_0_channelId0_f, &ds_flow_cam, watch_key->channel);
                SetIpeUserIdFlowCam(V, g_0_channelId1_f, &ds_flow_cam, 0x1FF);
                SetIpeUserIdFlowCam(V, g_0_channelId2_f, &ds_flow_cam, 0x1FF);
                SetIpeUserIdFlowCam(V, g_0_channelId3_f, &ds_flow_cam, 0x1FF);
                SetIpeUserIdFlowCam(V, g_1_channelId0_f, &ds_flow_cam, 0x1FF);
                SetIpeUserIdFlowCam(V, g_1_channelId1_f, &ds_flow_cam, 0x1FF);
                SetIpeUserIdFlowCam(V, g_1_channelId2_f, &ds_flow_cam, 0x1FF);
                SetIpeUserIdFlowCam(V, g_1_channelId3_f, &ds_flow_cam, 0x1FF);
            }
            if (p_trace->mode == CTC_DIAG_TRACE_MODE_USER)
            {
                SetBufStoreDebugCam(V, g_0_sourcePort_f, &ds_buff_store_cam, (SYS_MAP_CTC_GPORT_TO_DRV_GPORT(p_trace->pkt.user.src_port)));
                SetBufStoreDebugCam(V, g_1_sourcePort_f, &ds_buff_store_cam, 0xFFFF);
            }
            value = 1;
            cmd = DRV_IOW(DbgOamHdrAdj_t, DbgOamHdrAdj_debug1stPkt_f);
            CTC_ERROR_DUMP(DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &value));
            cmd = DRV_IOW(DbgOamHdrAdj_t, DbgOamHdrAdj_debugSessionEn_f);
            CTC_ERROR_DUMP(DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &value));
            goto install_ipe;
        case CTC_DIAG_TRACE_POINT_TM_BS:
            if (CTC_BMP_ISSET(watch_key->key_mask_bmp, CTC_DIAG_WATCH_KEY_MASK_CHANNEL))
            {
                SetBufStoreDebugCam(V, g_0_ppSrcPort_f, &ds_buff_store_cam, watch_key->channel);
                SetBufStoreDebugCam(V, g_1_ppSrcPort_f, &ds_buff_store_cam, 0x1FF);

                SetEpeHdrAdjustDebugCam(V, g_0_channelId_f, &ds_epe_dbg_cam, watch_key->channel);
                SetEpeHdrAdjustDebugCam(V, g_1_channelId_f, &ds_epe_dbg_cam, 0x1FF);
            }
            if (CTC_BMP_ISSET(watch_key->key_mask_bmp, CTC_DIAG_WATCH_KEY_MASK_SRC_GPORT))
            {
                SetBufStoreDebugCam(V, g_0_sourcePort_f, &ds_buff_store_cam, SYS_MAP_CTC_GPORT_TO_DRV_GPORT(watch_key->src_gport));
                SetBufStoreDebugCam(V, g_1_sourcePort_f, &ds_buff_store_cam, 0xFFFF);

                SetEpeHdrAdjustDebugCam(V, g_0_sourcePort_f, &ds_epe_dbg_cam, SYS_MAP_CTC_GPORT_TO_DRV_GPORT(watch_key->src_gport));
                SetEpeHdrAdjustDebugCam(V, g_1_sourcePort_f, &ds_epe_dbg_cam, 0xFFFF);
            }
            else if (p_trace->mode == CTC_DIAG_TRACE_MODE_USER)
            {
                SetBufStoreDebugCam(V, g_0_sourcePort_f, &ds_buff_store_cam, SYS_MAP_CTC_GPORT_TO_DRV_GPORT(p_trace->pkt.user.src_port));
                SetBufStoreDebugCam(V, g_1_sourcePort_f, &ds_buff_store_cam, 0xFFFF);

                SetBufStoreDebugCam(V, g_0_isSniffingPacket_f, &ds_buff_store_cam, 1);
                SetBufStoreDebugCam(V, g_1_isSniffingPacket_f, &ds_buff_store_cam, 0x1);
            }
            if (CTC_BMP_ISSET(watch_key->key_mask_bmp, CTC_DIAG_WATCH_KEY_MASK_SRC_LPORT))
            {
                SetBufStoreDebugCam(V, g_0_localPhyPort_f, &ds_buff_store_cam, watch_key->src_lport);
                SetBufStoreDebugCam(V, g_1_localPhyPort_f, &ds_buff_store_cam, 0x1FF);

                SetEpeHdrAdjustDebugCam(V, g_0_localPhyPort_f, &ds_epe_dbg_cam, watch_key->src_lport);
                SetEpeHdrAdjustDebugCam(V, g_1_localPhyPort_f, &ds_epe_dbg_cam, 0x1FF);
            }
            SetBufStoreDebugCam(V, g_0_isDebuggedPkt_f, &ds_buff_store_cam, 1);
            SetBufStoreDebugCam(V, g_1_isDebuggedPkt_f, &ds_buff_store_cam, 0x1);
            goto install_bsr;
        case CTC_DIAG_TRACE_POINT_TM_MET:
            value = 1;
            cmd = DRV_IOW(MetFifoCtl_t, MetFifoCtl_debugLookupEn_f);
            CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, DIAG_PP_EN(cmd, type_pp_bmp, CTC_DIAG_TRACE_POINT_TM_MET), &value));
            if (CTC_BMP_ISSET(watch_key->key_mask_bmp, CTC_DIAG_WATCH_KEY_MASK_DST_GPORT))
            {
                dest_map = SYS_ENCODE_DESTMAP(CTC_MAP_GPORT_TO_GCHIP(watch_key->dst_gport),
                                              CTC_MAP_GPORT_TO_LPORT(watch_key->dst_gport));
                dest_map |= (1 << 18);
                SetMetFifoDebugCam(V, g_0_destMap_f, &ds_met_fifo_cam, dest_map & 0x7FFFF);
                SetMetFifoDebugCam(V, g_1_destMap_f, &ds_met_fifo_cam, 0x7FFFF);

                SetEpeHdrAdjustDebugCam(V, g_0_destMap_f, &ds_epe_dbg_cam, dest_map & 0x7FFFF);
                SetEpeHdrAdjustDebugCam(V, g_1_destMap_f, &ds_epe_dbg_cam, 0x7FFFF);
            }
            goto install_met;
        case CTC_DIAG_TRACE_POINT_EPE_ADJ:
            if (CTC_BMP_ISSET(watch_key->key_mask_bmp, CTC_DIAG_WATCH_KEY_MASK_XDATA))
            {
                cmd = DRV_IOR(EpeHdrAdjustXCtl_t, DRV_ENTRY_FLAG);
                CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &xdata_ctl));
                SetEpeHdrAdjustXCtl(V, debugAuxDataSel_f, &xdata_ctl, watch_key->xdata->fields[0].offset/CTC_XDATA_WIDTH_4);
                cmd = DRV_IOW(EpeHdrAdjustXCtl_t, DRV_ENTRY_FLAG);
                CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &xdata_ctl));

                SetEpeHdrAdjustDebugCam(V, g_0_auxData_f, &ds_epe_dbg_cam, watch_key->xdata->fields[0].data);
                SetEpeHdrAdjustDebugCam(V, g_1_auxData_f, &ds_epe_dbg_cam, watch_key->xdata->fields[0].mask);
            }
            if (CTC_BMP_ISSET(watch_key->key_mask_bmp, CTC_DIAG_WATCH_KEY_MASK_CHANNEL))
            {
                SetEpeHdrAdjustDebugCam(V, g_0_channelId_f, &ds_epe_dbg_cam, watch_key->channel);
                SetEpeHdrAdjustDebugCam(V, g_1_channelId_f, &ds_epe_dbg_cam, 0x1FF);
            }
            if (CTC_BMP_ISSET(watch_key->key_mask_bmp, CTC_DIAG_WATCH_KEY_MASK_SRC_LPORT))
            {
                SetEpeHdrAdjustDebugCam(V, g_0_localPhyPort_f, &ds_epe_dbg_cam, watch_key->src_lport);
                SetEpeHdrAdjustDebugCam(V, g_1_localPhyPort_f, &ds_epe_dbg_cam, 0x1FF);
            }
            if (CTC_BMP_ISSET(watch_key->key_mask_bmp, CTC_DIAG_WATCH_KEY_MASK_SRC_GPORT))
            {
                SetEpeHdrAdjustDebugCam(V, g_0_sourcePort_f, &ds_epe_dbg_cam, SYS_MAP_CTC_GPORT_TO_DRV_GPORT(watch_key->src_gport));
                SetEpeHdrAdjustDebugCam(V, g_1_sourcePort_f, &ds_epe_dbg_cam, 0xFFFF);
            }
            else if (p_trace->mode == CTC_DIAG_TRACE_MODE_USER)
            {
                SetBufStoreDebugCam(V, g_0_sourcePort_f, &ds_buff_store_cam, SYS_MAP_CTC_GPORT_TO_DRV_GPORT(p_trace->pkt.user.src_port));
                SetBufStoreDebugCam(V, g_1_sourcePort_f, &ds_buff_store_cam, 0xFFFF);

                SetEpeHdrAdjustDebugCam(V, g_0_isSniffingPacket_f, &ds_epe_dbg_cam, 1);
                SetEpeHdrAdjustDebugCam(V, g_1_isSniffingPacket_f, &ds_epe_dbg_cam, 1);

            }
            goto install_epe;
        case CTC_DIAG_TRACE_POINT_OAM_ADJ:
            if (CTC_BMP_ISSET(watch_key->key_mask_bmp, CTC_DIAG_WATCH_KEY_MASK_MEP_INDEX))
            {
                uint32 ma_index = 0;
                value = watch_key->mep_index;
                cmd = DRV_IOW(DbgOamHdrAdj_t, DbgOamHdrAdj_mepIndex_f);
                CTC_ERROR_DUMP(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
                cmd = DRV_IOW(DbgOamApsSwitch_t, DbgOamApsSwitch_mepIndex_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
                cmd = DRV_IOW(DbgOamApsProcess_t, DbgOamApsProcess_mepIndex_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
                value = 0;
                cmd = DRV_IOW(DbgOamHdrAdj_t, DbgOamHdrAdj_debugSessionEn_f);
                CTC_ERROR_DUMP(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
                value = 1;
                cmd = DRV_IOW(DbgOamApsSwitch_t, DbgOamApsSwitch_debugUseMepIdx_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
                cmd = DRV_IOW(DbgOamApsProcess_t, DbgOamApsProcess_debugUseMepIdx_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
                cmd = DRV_IOW(DbgOamHdrAdj_t, DbgOamHdrAdj_debugUseMepIdx_f);
                CTC_ERROR_DUMP(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
                cmd = DRV_IOR(DsEthMep_t, DsEthMep_isBfd_f);
                CTC_ERROR_DUMP(DRV_FIELD_IOCTL(lchip, watch_key->mep_index, cmd, &value));
                if (value)
                {
                    cmd = DRV_IOR(DsBfdMep_t, DsBfdMep_maIndex_f);
                }
                else
                {
                    cmd = DRV_IOR(DsEthMep_t, DsEthMep_maIndex_f);
                }
                CTC_ERROR_DUMP(DRV_FIELD_IOCTL(lchip, watch_key->mep_index, cmd, &ma_index));
                value = 1;
                cmd = DRV_IOW(DsMa_t, DsMa_debugSessionEn_f);
                CTC_ERROR_DUMP(DRV_FIELD_IOCTL(lchip, ma_index, cmd, &value));
            }
            else
            {
                value = 1;
                cmd = DRV_IOW(DbgOamHdrAdj_t, DbgOamHdrAdj_debugSessionEn_f);
                CTC_ERROR_DUMP(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
                value = 0;
                cmd = DRV_IOW(DbgOamHdrAdj_t, DbgOamHdrAdj_debugUseMepIdx_f);
                CTC_ERROR_DUMP(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
            }
            break;
        case CTC_DIAG_TRACE_POINT_OAM_TX:
            if (CTC_BMP_ISSET(watch_key->key_mask_bmp, CTC_DIAG_WATCH_KEY_MASK_MEP_INDEX))
            {
                uint32 ma_index = 0;
                value = watch_key->mep_index;
                cmd = DRV_IOW(DbgOamTxProc_t, DbgOamTxProc_mepIndex_f);
                CTC_ERROR_DUMP(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
                value = 1;
                cmd = DRV_IOW(DbgOamTxProc_t, DbgOamTxProc_debugUseMepIdx_f);
                CTC_ERROR_DUMP(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
                cmd = DRV_IOR(DsEthMep_t, DsEthMep_isBfd_f);
                CTC_ERROR_DUMP(DRV_FIELD_IOCTL(lchip, watch_key->mep_index, cmd, &value));
                if (value)
                {
                    cmd = DRV_IOR(DsBfdMep_t, DsBfdMep_maIndex_f);
                }
                else
                {
                    cmd = DRV_IOR(DsEthMep_t, DsEthMep_maIndex_f);
                }
                CTC_ERROR_DUMP(DRV_FIELD_IOCTL(lchip, watch_key->mep_index, cmd, &ma_index));
                value = 1;
                cmd = DRV_IOW(DsMa_t, DsMa_debugSessionEn_f);
                CTC_ERROR_DUMP(DRV_FIELD_IOCTL(lchip, ma_index, cmd, &value));
            }
            else
            {
                value = 1;
                cmd = DRV_IOW(DbgOamTxProc_t, DbgOamTxProc_debug1stPkt_f);
                CTC_ERROR_DUMP(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
            }
            goto install_bsr;
            break;
        default:
            break;
    }
    return CTC_E_NONE;
install_ipe:
    if (p_trace->mode == CTC_DIAG_TRACE_MODE_USER)
    {
        SetIpeUserIdFlowCam(V, g_0_isDebuggedPkt_f, &ds_flow_cam, 1);
        SetIpeUserIdFlowCam(V, g_1_isDebuggedPkt_f, &ds_flow_cam, 0x1);

        SetIpeUserIdFlowCam(V, g_0_isSniffingPacket_f, &ds_flow_cam, 1);
        SetIpeUserIdFlowCam(V, g_1_isSniffingPacket_f, &ds_flow_cam, 0x1);
    }
install_bsr:
    SetBufStoreDebugCam(V, g_0_isDebuggedPkt_f, &ds_buff_store_cam, 1);
    SetBufStoreDebugCam(V, g_1_isDebuggedPkt_f, &ds_buff_store_cam, 0x1);
    cmd = DRV_IOW(BufStoreDebugCam_t, DRV_ENTRY_FLAG);
    SYS_SET_TBL_ALL_DP(lchip, DIAG_PP_EN(cmd, type_pp_bmp, CTC_DIAG_TRACE_POINT_TM_BS), ds_buff_store_cam);
    io_valid1 = 1;
    value =1;
    cmd = DRV_IOW(BufStoreDebugCtl_t, BufStoreDebugCtl_debugLookupEn_f);
    SYS_SET_FIELD_TBL_ALL_DP(lchip, cmd, value);
install_met:
    if (watch_point != CTC_DIAG_TRACE_POINT_TM_MET)
    {
        SetMetFifoDebugCam(V, g_0_isDebuggedPkt_f, &ds_met_fifo_cam, 1);
        SetMetFifoDebugCam(V, g_1_isDebuggedPkt_f, &ds_met_fifo_cam, 0x1);
    }
    else
    {
        value =0;
        cmd = DRV_IOW(BufStoreDebugCtl_t, BufStoreDebugCtl_debugLookupEn_f);
        SYS_SET_FIELD_TBL_ALL_DP(lchip, DIAG_PP_EN(cmd, type_pp_bmp, CTC_DIAG_TRACE_POINT_TM_MET), value);
    }
    cmd = DRV_IOW(MetFifoDebugCam_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DIAG_PP_EN(cmd, type_pp_bmp, CTC_DIAG_TRACE_POINT_TM_MET), &ds_met_fifo_cam));
    io_valid2 = 1;
    value = 1;
    cmd = DRV_IOW(MetFifoCtl_t, MetFifoCtl_debugLookupEn_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, DIAG_PP_EN(cmd, type_pp_bmp, CTC_DIAG_TRACE_POINT_TM_MET), &value));
install_epe:
    if (watch_point == CTC_DIAG_TRACE_POINT_EPE_ADJ)
    {
        value =0;
        cmd = DRV_IOW(BufStoreDebugCtl_t, BufStoreDebugCtl_debugLookupEn_f);
        SYS_SET_FIELD_TBL_ALL_DP(lchip, cmd, value);
    }
    else
    {
        SetEpeHdrAdjustDebugCam(V, g_0_isDebuggedPkt_f, &ds_epe_dbg_cam, 1);
        SetEpeHdrAdjustDebugCam(V, g_1_isDebuggedPkt_f, &ds_epe_dbg_cam, 0x1);
    }

    cmd = DRV_IOW(EpeHdrAdjustDebugCam_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DIAG_PP_EN(cmd, type_pp_bmp, CTC_DIAG_TRACE_POINT_EPE_ADJ), &ds_epe_dbg_cam));
    if (!io_valid2)
    {
        cmd = DRV_IOW(MetFifoDebugCam_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DIAG_PP_EN(cmd, type_pp_bmp, CTC_DIAG_TRACE_POINT_TM_MET), &ds_met_fifo_cam));
    }
    if (!io_valid1)
    {
        cmd = DRV_IOW(BufStoreDebugCam_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DIAG_PP_EN(cmd, type_pp_bmp, CTC_DIAG_TRACE_POINT_TM_BS), &ds_buff_store_cam));
    }
    cmd = DRV_IOW(IpeUserIdFlowCam_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &ds_flow_cam));

    value = 1;
    cmd = DRV_IOW(DebugSessionStatusCtl_t, DebugSessionStatusCtl_isFree_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &value));
    cmd = DRV_IOW(EpeHdrAdjustChanCtl_t, EpeHdrAdjustChanCtl_debugIsFree_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, DIAG_PP_EN(cmd, type_pp_bmp, CTC_DIAG_TRACE_POINT_EPE_ADJ), &value));
    cmd = DRV_IOW(EpeHdrAdjustCtl_t, EpeHdrAdjustCtl_debugLookupEn_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, DIAG_PP_EN(cmd, type_pp_bmp, CTC_DIAG_TRACE_POINT_EPE_ADJ), &value));
    cmd = DRV_IOW(IpeUserIdFlowCtl_t, IpeUserIdFlowCtl_flowEn_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, DRV_CMD_PP_EN(cmd), &value));
    return CTC_E_NONE;
}

#endif

